Arguments, callee, caller details in javascript, calleecaller

Source: Internet
Author: User

Arguments, callee, caller details in javascript, calleecaller

What is arguments?

When calling a function, arguments creates a similar array but not an array object, and stores the parameters actually passed to the function, it is not limited to the parameter list of function declaration.

What does Nima mean?

Write a demo. See the code below.

<! DOCTYPE html> 

Run the code and use the chrome debugger to obtain

I use instanceof to judge arguments. According to the print result, arguments is an object.

Then expand the output arguments. We can see that it contains many attributes, as well as callee.

Next, we modify the above Code and pass parameters to the obj function when calling the obj function, but the obj function does not have parameters.

For specific code, see

<! DOCTYPE html> 

Use the chrome debugger to obtain

As you can see, arguments contains three parameters we pass to it: "monkey", "love", and 24.

So why does arguments actually store the parameters passed to the function, rather than the declared parameters.

What is callee?

Callee is a member of the arguments object. Its value is "Function object being executed ".

What does it mean?

Let's write a demo and check the output.

The code and result are shown in the following figure.

<! DOCTYPE html> 

As shown in the preceding figure, arguments. callee is a function pointing to the arguments object. Here it is obj.

What is caller?

Caller is an attribute of a function object that stores the function that calls the current function.

Note: It is called. It not only contains closures. If there is no parent function, it is null.

It's still the same. Let's keep writing a demo.

The Code is as follows:

<! DOCTYPE html> 

Open the chrome debugger.

Can I understand caller in combination with code and understanding?

Articles you may be interested in:
  • Example and understanding of arguments, caller, callee, call, and apply in javascript
  • Js arguments, jcallee caller usage Summary
  • Summary of arguments, caller, callee, and apply in js
  • Js implicit parameters (arguments, callee, caller) Usage

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.