본문 바로가기

programming/javascript

prettier html 적용 끄기(mac vscode) vscode 1. command + , 2. prettier 입력 후 settings 탭으로 간다. 3. disable language 에서 html 을 추가해 준다. 더보기
closure, callback 예시 만들기 클로저란? 함수가 종료되어도 지역변수가 사라지지 않고 활용되는 것. -출처: 모던 웹을 위한 JavaScript jQuery 입문 책을 보고 예시를 만들어 보았다. 콜백(callback) 예시. 콜백이란, 매개변수에 인자로 함수가 전달되는 것. 더보기
생활코딩 자바스크립트 class 강의를 보고 만든 예제 class Students { constructor (name, scoreA, scoreB) { this.name = name; this.scoreA = scoreA; this.scoreB = scoreB; } sum () { return (this.scoreA + this.scoreB); } info () { return `name: ${this.name}, total: ${this.sum()}`; } } var stu001 = new Students('mina', 100, 70); var stu002 = new Students('lily', 90, 60); console.log(stu001); // Students { name: 'mina', scoreA: 100, scoreB: 70 } consol.. 더보기
생활코딩 자바스크립트 this, prototype 강의를 보고 만든 예제 var student001 = { name: 'sherlock', scoreA: 90, scoreB: 80, scoreSum: scoreSum }; var student002 = { name: 'lily', scoreA: 80, scoreB: 70, scoreSum: scoreSum }; function scoreSum () { return `name: ${this.name}, total: ${this.scoreA + this.scoreB}`; } console.log(student001.scoreSum()); console.log(student002.scoreSum()); 생활코딩 this 강의를 보고 예제를 만들어 보았다. https://www.opentutorials.org/module/4047/2.. 더보기
Mac os brew 이용 nodejs 설치하기 brew 를 설치한 김에 nodejs 도 설치할 수 있는 지 구글링을 하니 역시 가능하다. brew가 설치되어 있는 환경에서 $ brew install node 라고 명령어를 입력하면 된다. 설치 후에 node -v npm -v 를 통해 버전을 확인할 수 있다. 현재 node 12는 lts 버전이 아니므로 최신 lts 버전으로 변경하고 싶었다. 참고한 블로그 주인께서 해당 내용도 작성해 주셔서 내용을 보고 변경하였다. $ sudo npm install -g n $ sudo n lts 위 코드를 입력하면 최신 lts 10 버전으로 변경된다. 자세한 내용은 아래 블로그에서 확인해보자. 참고: https://deok.me/entry/n-%EC%9D%84-%ED%86%B5%ED%95%98%EC%97%AC-Nod.. 더보기
node js mysql 연동 에러 Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client node js mysql 연동시 위와 같은 에러가 발생하였다.이유는 잘 모르겠지만, 검색 끝에 대충 해결하였다. 기존에 설치된 mysql 을 삭제하고 재설치.설치할 때Strong passord~~ 이거 말고legacy 로 시작하는 것을 선택하고 설치하여야 한다. 더보기
JS) call 예제 123456789101112131415161718192021//자바스크립트 함수, callconst rose = {name : "로즈-장미"};const lily = {name : "릴리-백합"};const mugunghwa = {name : "무궁화-무궁화"}; function flower(){ return `flower : ${this.name}`;} console.log(flower.call()); // flower :console.log(flower.call(lily)); // flower : 릴리-백합 function updateFlower(languge, japanese){ this.languge = languge; this.japanese = japanese;} updateFlower.cal.. 더보기
js) object - {}, [] 테스트 1234567891011let obj = { 0 : "a", 1 : "b", 2 : "c", 3 : 4, "4" : 5, test : "test", "num" : 100}; let arr = ['a','b','c',4,5];cs 자바스크립트 오브젝트 테스트 key : value 라고 할 때 key 에는 숫자를 사용해서는 안 된다고 한다 더보기