Functions are link to Function.prototype. Function.prototype is linked to Object.prototype.
Since functions are object, they can have property, method, they can be passed to functions.
The missing parameter will have value undefined
A function always returns a value. If the return value is not specified, then undefined is returned.
every function receives two additional parameters: this and arguments.
Invocation
pattern of invocation:
the method invocation pattern - When a function is stored as a property of an object, we call it a method, this is bounded to the object
the function invocation pattern - When a function is NOT the property of an object. this is bounded to global object, ( window in DOM ). THIS IS A DESIGN MISTAKE, this should be bounded to ccurrent context instead
the constructor invocation pattern - this binds to newly created object
and the apply invocation pattern
Inner Functions
function foo(a, b) {
function bar() {
return a + b;
}
return bar();
}
foo(1, 2);
document.addEventListener("click", function(evt) {
alert("You clicked the page.");
});