JS call Apply caller callee bind

Source: Internet
Author: User

Call apply bind acts similarly. That is, one method of calling an object, replacing the current object with another object.

Pager

Syntax: Call ([thisobj[,arg1[, arg2[, [,. ArgN]]])

Apply
Syntax: Apply ([Thisobj[,argarray]])

Bind

Call () apply () is immediately called the corresponding function, and bind () does not, bind () will generate a new function, the bind () function parameter is consistent with call (), the first parameter is a bound object, and then accept the variable arguments passed to the function. When the new function generated by bind () returns, it is time to tune

var m = {
"X": 1
};
function foo (y) {
Alert (this.x + y);
}
Foo.apply (M, [5]);
Foo.call (M, 5);
var foo1 = Foo.bind (M, 5);
Foo1 ();

Caller

When a function calls another function, the called function automatically generates a caller property that points to the function object that called it. If the function is not currently called, or is not called by another function, caller is null.

callee

When a function is called, its Arguments.callee object points to itself, which is a reference to itself.
Because arguments is valid when a function is called, Arguments.callee does not exist when the function is not called (that is, Null.callee), and referencing it produces an exception.

arguments: When a function is called, a hidden object named arguments is automatically generated inside the function. The object is similar to an array, but not an array, but an object. You can use [] to get the arguments that are passed when the function is called.

JS call Apply caller callee bind

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.