JavaScript pass scope to another function

后端 未结 10 697
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 16:48

Is it possible to somehow pass the scope of a function to another?

For example,

function a(){
   var x = 5;
   var obj = {..};
   b()         


        
10条回答
  •  死守一世寂寞
    2020-12-23 17:36

    No.

    You're accessing the local scope object. The [[Context]].

    You cannot publicly access it.

    Now since it's node.js you should be able to write a C++ plugin that gives you access to the [[Context]] object. I highly recommend against this as it brings proprietary extensions to the JavaScript language.

提交回复
热议问题