javascript - Way does not passing an argument to an anonymous function cause it to return a function -


why passing passing argument anonymous function effect results? instance, below script shows a1 function(), , a2 array.

var a1=(function(){return [1*2,2*2,3*2];}); var a2=(function(v){return [1*v,2*v,3*v];})(2); console.log(a1,a2); 

results:

function() [2, 4, 6] 

your first line of code never calls function.

writing var = function() { ... } assign function a.

your second line call function, other function call, using (2).


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -