실행 컨텍스트에 대해 알아보겠습니다. 실행 컨텍스트란 간단하게 코드가 실행되는 환경이라고 할 수 있습니다. 실행 컨텍스트는 전역 컨텍스트와 함수 컨텍스트로 구분됩니다. var a = "A" function func1(){ console.log(a); } function func2(){ var a = "D" func1(); } func2(); //"A" 코드를 실행하면 전역 컨텍스트가 생성되고, 함수 호출 시 함수 컨텍스트가 생성됩니다. 컨텍스트 생성 시 안에 변수객체(arguments, variable), scope chain, this가 생성됩니다. 컨텍스트 생성 후 함수가 실행되는데, 사용되는 변수들은 변수 객체 안에서 값을 찾고, 없다면 스코프 체인을 따라 올라가며 찾습니다. 함수 실행이 마무리되면..
node-sass에서 watch 옵션을 사용하여 저장 시 위와 같은 오류가 발생 할때가 있습니다. { "status": 3, "message": "File to read not found or unreadable: FILE.scss", "formatted": "Internal Error: File to read not found or unreadable: FILE.scss\n" } node-sass의 모듈 내부를 수정하여 해결 하였습니다. 모듈 폴더로 들어가서 해당 내용으로 교체 하였습니다. https://github.com/marcosbozzani/node-sass/blob/bug-vscode-watch/lib/render.js marcosbozzani/node-sass :rainbow: Node.js..
자바스크립트에서의 this에 대해 알아보겠습니다. 기본적으로 자바스크립트에서 this는 전역 객체인 window 입니다. console.log(this); //Window 위와 같이 window 객체가 출력됩니다. 함수를 선언하고 호출 해 보겠습니다. function thisCheck(){ return this; } console.log(thisCheck()); //Window 다음은 객체에 메소드를 만들고 호출했을때의 결과 입니다. const obj = { thisCheck: function(){ return this; } } console.log(obj.thisCheck()); //obj this는 obj 객체가 됩니다. 메서드를 변수에 저장하고 실행 시 어떻게 되는지 확인 해 보겠습니다. const..