Understanding of several concepts in Javascript

Source: Internet
Author: User

Arguments:

The call parameter of the function being executed by the object.

Arguments is a hidden object created in addition to the specified parameters when calling a function. Arguments is an object similar to an array but not an array. It is similar to an array because it has the same access nature and method as an array, you can use arguments [N] to access the values of a single parameter and have the Length attribute of the array length. In addition, the arguments object stores the parameters actually passed to the function, not limited to the list of parameters defined in the function declaration, and cannot explicitly create the arguments object. The arguments object is available only when the function starts.

Caller:

Indicates the name of the executed function.

For a function, the caller attribute is defined only when the function is executed. If the function is called by the top layer, caller contains null. If the caller attribute is used in the string context, the result is the same as functionname. tostring, that is, the decompilation Text of the function is displayed.

Callee:

Indicates the function object being executed.

The callee attribute is a member of the arguments object. It indicates a reference to the function object itself, which facilitates recursion of anonymous functions or ensures function encapsulation. This attribute is only available when the related function is being executed. It should also be noted that callee has the Length attribute, which is sometimes used for verification. Arguments. length is the length of the real parameter, and arguments. callee. length is the length of the form parameter, which can be used to determine whether the length of the form parameter is consistent with the actual length.

Apply, call:

All functions are bound to another object for running. The two functions are different only when defining parameters:
apply (thisarg, argarray );
call (thisarg [, arg1, arg2…] ]);
that is, all the internal this pointer of the function will be assigned a value of thisarg, which can be used to run the function as a method of another object.

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.