nmsdvid
nmsdvid

Reputation: 2898

How to unnest functions in javaScript

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

    };

Upvotes: 0

Views: 457

Answers (1)

eljenso
eljenso

Reputation: 17037

There are no nested functions in your code snippet.

You are using assignment as an expression though, using its return value to 'chain' assignments.

Unchaining the assignment would simply amount to

function3 = function2;
document.onmouseup = function3;

Upvotes: 1

Related Questions