In JavaScript, a function is actually an object
The function name is actually a pointer to a function object = = Assigns the function name to null and the function still exists
+ = The function name that uses the sack brackets is to access the function pointer instead of calling the function
1, the function is not overloaded, declaring two functions with the same name, which overrides the former
2, function declaration and function expression
Two ways to declare a function:
function functionname () {Do something}
var functionname = new function () {do something};
The difference between the two approaches is that using alert (functionname) before the latter results in an error.
3, function as a value
The function name can be used as a normal variable, and the function name can be passed as a parameter to another function, or a function can be returned by a function.
4, internal properties of the function
The function has 2 internal objects: arguments and this. Arguments is a parameter array that has a
The Callee property, which points to the function that owns this arguments. This represents the environment object to which the function is executed.
Alert (Arguments.callee)//Return function code
Alert (this)//Return to Object Window
Alert (This.caller)//return undefined
The caller property of the function: Returns the function that called the current function.
5, properties and methods of the function:
Length: Returns the number of arguments to the function
Prototype: returns a reference to the object type prototype
Apply (): Invokes a function in a specific scope. Accepts 2 parameters, scope and parameter array
Call (): Invokes a function in a specific scope, accepts several parameters, the first parameter is scope, and the other parameter is
Arguments passed to the calling function
You can use Call (widow) or apply (window) to extend the scope of the function to all
Bind (): Creates a function instance, and the parameter of bind () is the scope of the instance function.
toLocaleString () and ToString (): Returns the source code of the function
function fun1 () {alert ("good"); } var Newf = Fun1.bind (); alert (FUN1); Returns the source code of the function Newf (); Good
This article is from the "Wanghaz Learning" blog, so be sure to keep this source http://10703847.blog.51cto.com/10693847/1697942
"JavaScript" "learning" 3. Function types in JavaScript