var hh = 0; funcvoid(param1, param2, function () { hh = param1 + param2; }); alert(hh); 

As a result, 0 is stored in hh, what should be done to write param1 + param2 ??

Reported as a duplicate by members of aleksandr barakin , Community Spirit Nov 26 '16 at 19:13 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    Looks like you mean the following

     <script> hh = 0; ( function( param1, param2, func ) { hh = func( param1, param2 ); } )( 10, 20, function ( param1, param2) { return param1 + param2; } ); alert(hh); </script>