Js Function, js function

Source: Internet
Author: User

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"]);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.