반응형
vscode 단축키
코드 언어 모드 선택 : 컨트롤 + K M
- 웹/VSCODE
- · 2025. 5. 12.
반응형
https://iyerl.github.io/dev/sourcetree-compare.html [Sourcetree] 외부 비교 - Visual CodeSourceTree, 그리고 Compare 도구로써 Visual Codeiyerl.github.io
코드 언어 모드 선택 : 컨트롤 + K M
📚 자바스크립트에서 this, var, new 개념 완전 정리1. this는 함수 안에서 "누가 호출했느냐"에 따라 달라진다호출 방식 this가 가리키는 대상new 함수()새로 만들어진 객체 (인스턴스)그냥 함수() 호출전역 객체 (브라우저에선 window)메서드에서 obj.함수()그 객체 (obj)strict 모드에서 함수()undefined (전역도 아님!)2. this를 쓸 땐 무조건 new와 함께 써야 안전하다function MyFunc(val) { this.a = val;}new MyFunc('hello'); // this.a는 새 객체 안에 들어감🔸 만약 new 없이 호출하면MyFunc('hello');console.log(window.a); // ❗ 전역 변수 생김 (this가 win..