전역 문맥에서의 this

함수 문맥에서의 this

1. 단순 호출

const myFunc = function() {
	console.log(this);
}
// 브라우저
myFunc(); // window

// Node.js
myFunc(); // global

2. method

const myObj = {
	data: 1,
	myFunc() {
		console.log(this);      // myObj
		console.log(this.data); // 1
	};
};

myObj.myFunc(); // myObj

3. nested