const a = "Hello";
function outer() {
let a = "bye";
console.log(a);
function inner() {
console.log(a);
}
inner();
}
outer(); // bye bye
console.log(a); // Hello
let someValue = 'hello';
function outerFunc() {
console.log(this.someValue);
this.innerFunc();
}
const obj = {
someValue : 'world',
outerFunc,
innerFunc : function() {
console.log("innerFunc's this : ", this);
}
}
obj.outerFunc(); // world, innerFunc's this: obj
outerFunc() // undefined, error
댓글