July 2011
Intermediate to advanced
276 pages
5h 11m
English
Functions have names, but anonymous functions do not; MooTools uses them everywhere.
Anonymous functions are one-time use like disposable lighters. In MooTools, we use them to one-time define a method; reusable disposable functions!
To define and call an anonymous function raw JavaScript wraps a function in parentheses:
(function(){document.title=location.href;alert('done');})();
Nothing is returned, and the function is not assigned to a function identifier; when the () function syntax is appended, the function self-executes.
MooTools' use differs slightly in that we will pass this anonymous function as an argument to a MooTool object and bind it to an identifier; ...