You can use the 'return' to exit the function immediately, any other lines of code will be ignored.
Function overloading is not allowed, the last function (from top to bottom is used)
There is parameter flexibility

Anonymous and Assigned

The function name can be omitted but it is best practice to always include a name so it appears on the call stack when debugging.

var AddNumbers = function () { 
   return arguments[0] + arguments[1];

Anonymous without Return

This function has no parameters
Functions do not need names and can be passed around anonymously
Anonymous functions are used heavily in jQuery

( function() { 
   //some code
} )

Anonymous with Return

var myResult ( function() { 
   return arguments[0] + arguments[1];
} ) (1,2);

alert( function() { return arguments[0] + arguments[1] }) (1,2)); 

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext