Immediate Parent function is absent from returned function's scope chain

22 Views Asked by At

I've been doing some research on the [[scope]] property of function object.[[scope]] should incorporate all the outer function's variable object in addition to global object.

Here, the innermost function which returns from the Inner function, should contain both Inner+Outer+Global variable object assigned to it's scope chain.But it only has Outer+Global variable objects assigned to it's scope chain.

Why Inner function is absent from the [[scope]] chain of the returned function which happens to be the immediate parent of returned function. Any suitable explanation for this behavior?

function Outer(){
   var a = 10
   return function Inner(){
     var b = 22
     console.log('ball')
     return function(){

        console.log(a+b)
     }

  }

}

var oppa = Outer()()
console.dir(oppa)

Result :

enter image description here

0

There are 0 best solutions below