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
Post a Comment