Function statements function double(x){ console.log(2*x); } double(2); // invoke the function Function expressions var doubleFunction = function(x){ console.log(2*x); } doubleFunction(2); // invoke the functionThere are some benefits of function expressions over statements, for example they are anonymous functions, they can be used as closures, as arguments to other functions and as IIFEs.
No comments:
Post a Comment