JS
const obj = {
id: 1,
getId: function() {
return this.id;
}
}
//매소드에 소유객체가 있으면 obj 는 this 가 된다.
console.log(this.id);
console.log(obj.id);
console.log(obj.getId();
전역 객체 에 연결된다.JS
function caller(fn) {
console.log('caller ==> ', fn())
}
const obj = {
id: 1,
getId: function() {
return this.id;
}
}
console.log('this.id ==> ', this.id)
console.log(this.id);
console.log(obj.getId();
caller(obj.getId)