Js Function, js function
1. The function is actually an object typeof functionName → function. It uses instanceof to determine which class it belongs.
2. The function name is actually a pointer pointing to a function body.
3. The function has two internal objects: arguments and this. Arguments can not only point to the parameters passed in by the function, but also, arguments. callee points to a function. For example, if the function outer is called, it can be written as outer () and changed to arguments. callee ();
This refers to an execution environment. For example, if we call the function outer separately, this is the window. If we use call or apply, we can control the call object of the function, that is, this object,
Function outer (){}
Var obj = new Object ();
Outer. call (obj); this points to obj.
We can see that the two methods apply and call are both method calls. The method can be called by method name. Why do we need call and apply. Because they can control this object. If outer. call (null) or
Outer. call (undefined), then it points to the window object. The difference between call and apply lies in the second parameter. The second parameter of apply can only be arguments and an array, while call is listed one by one, for example
Outer. call (obj, "red", "blue"); apply is outer. apply (obj, ["red", "blue"]);