How do you call a local function?

前端 未结 3 748
失恋的感觉
失恋的感觉 2021-01-07 09:54

So heres the basic outline

function x(){
   // some code 
   function y(){
   //some more code
  }
}

function z(){
  // how do i call function y?
}
<         


        
3条回答
  •  离开以前
    2021-01-07 10:29

    function x(){
       // some code 
      this.y=function(){
       //some more code
      }
    }
    
    function z(){
     var fun_x=new x();
    fun_x.y();
    }
    

    the global namespace is still as it was before this code

提交回复
热议问题