JavaScript Arguments,callee,caller in detail _ basic knowledge

Source: Internet
Author: User

What is arguments?

Arguments is a similar array that is created when a function is called, but is not an array object, and it stores the arguments that are actually passed to the function, and is not limited to the argument list of the function declaration.

What do you mean, "ni"?

Write a demo, see the code.

<! DOCTYPE html>
   
 

Run the code, through the Chrome debugger, you can get the following figure

I use instanceof to judge arguments, from the effect of printing, arguments is an object.

then expand the print out of the arguments, you can learn from the above, it contains a number of properties, Callee also.

Next, we modify the code above to pass arguments to it when the obj function is called, but the obj function has no arguments.

See below for specific code

<! DOCTYPE html>
   
 

Using the Chrome debugger, you can get the image below

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

So, why is arguments a parameter stored that is actually passed to a function instead of a function declaration?

What is callee?

Callee is a member of the arguments object whose value is "the function object being executed."

What does that mean?

Let's write a demo and see how the output turns out.

Code and result graphs see below

<! DOCTYPE html>
   
 

From the picture above, Arguments.callee is the function that points to the arguments object of the parameter, here is obj.

What is caller?

Caller is a property of a function object that holds the function that calls the current function.

Note that is called. Not just closures. Null if there is no parent function.

Still the same as usual, we have been to write a demo to see.

The code is as follows:

<! DOCTYPE html>
   
 

Open the Chrome debugger to get a picture of the effect

Combining the code and the above figure understanding, does this understand caller?

Related Article

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.