0

I need some help to understand nested function in javaScript. So, below is a fictional script with nested functions, can somebody help me to understand how to unnest them ?


    function start (){

        document.ontouchmove = function1;

        document.onmouseup = function3 = function2; 

    };


    function function1 (){

        //code

    };


    function function2 (){

        // code

    };


    function function3 (){

        //code

    };
4

1 回答 1

1

您的代码片段中没有嵌套函数。

不过,您将赋值用作表达式,将其返回值用于“链式”赋值。

解除分配的链接只会相当于

function3 = function2;
document.onmouseup = function3;
于 2012-05-31T08:20:10.607 回答