The arguments in Javascript

Source: Internet
Author: User

Arguments is a parameter of the currently executing function that holds the arguments that are currently called by the functions. How to use: function.arguments[i]. where function. is an option and is the name of the function that is currently executing. Arguments cannot be created, it is a parameter of the function itself and can only be used if the function starts execution. Although the use of arguments is much like an array, it is not an array. Here's a demonstration with an example:
function Argumentstest (A, b) {        alert (typeof arguments);} (argumentstest);

As you can see, this is the browser window that pops up, and the arguments type is object.

function Argumentstest (A, b) {        //alert (typeof arguments);        alert (arguments.length);} (argumentstest);
Popup results:
function Argumentstest (A, b) {        //alert (typeof arguments);        alert (arguments.length);        Alert (arguments[1]);} (argumentstest);
Popup Result: Note The following code:
function Argumentstest (A, b) {    //alert (typeof arguments);    alert (arguments.length);    Alert (arguments[1]);} Argumentstest (1,2,3,4);
Popup Result: The result of the popup is 4. Here is the callee method, which returns the function object that is being executed.
function Argumentstest (A, b) {    //alert (typeof arguments);    alert (arguments.length);    Alert (arguments[1]);    alert (Arguments.callee);    alert (arguments.callee.length);} Argumentstest (1,2,3,4);
Popup Result: The following is the key, arguments.callee.length return how much?
function Argumentstest (A, b) {    //alert (typeof arguments);    alert (arguments.length);    Alert (arguments[1]);    alert (Arguments.callee);    alert (arguments.callee.length);} Argumentstest (1,2,3,4);
Popup Result: Arguments.length Returns the length of the argument, which is 4, and arguments.callee.length returns the length of the parameter, only 2.

The arguments in Javascript

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.