JavaScript pass scope to another function

后端 未结 10 580
被撕碎了的回忆
被撕碎了的回忆 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:26

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

提交回复
热议问题