본문 바로가기
공부낙서장

24.10.16 면접 전 문제풀이 복기

by 곰인간 2024. 10. 16.

 

 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

 

댓글