- The length property of the Function object returns the number of parameters of the time functions, and the length property of the arguments object returns the number of arguments for the function. If the function is not an anonymous function, Arguments.callee is equivalent to the function name.
- About Call and apply
function f () {
THIS.A = ' a ';
this.b = function () {
Alert (' B ')
}
}
function e () {
F.call (this);
alert (a);
}
E ()//' a '
The above example shows that if the external function is called dynamically using the call and apply methods within the function body and the first parameter issued by the call,apply is set to this, then the current function e inherits all members of F, using call, The Apply method can copy the internal variables of the calling function to the current function body, changing the internal this point of function f to function E, so that e can refer to the F internal members.
- Function call pattern
- Method invocation pattern. When a function is saved as a property of an object, it becomes a method. When a method is called, this is bound to the current object.
- The function invocation pattern. When a function is not a property of an object, it is invoked as a function. This binds to the global object.
- constructor invocation mode. If the call is preceded by the new operator in front of a function, a new instance object that hides the prototype prototype object linked to the function is created, and this is bound to the new instance object. (constructor function usually starts with uppercase letters)
- The Apply invocation pattern. Use this method to call the function and modify the function body this value.
"Front-end learning" functional programming related