javascript functions notes
Javascript advanced tutorial for beginners and experienced developers gives good examples for them.
Anonymous functions could be useful for:
To call anonymous functions use arguments.callee()
A well-documented code snippet for how function could be attached to some class.
Reference: JSDoc constructor example.
/** @constructor */
Person = function() {
this.say = function() {
return "I'm an instance.";
}
function say() {
return "I'm inner.";
}
}
Person.say = function() {
return "I'm static.";
}
var p = new Person();
p.say(); // I'm an instance.
Person.say(); // I'm static.
// there is no way to directly access the inner function from here
TODO: document this tutorial.