JS Understanding Parameter-arguments Object

Source: Internet
Author: User

JS Understanding Parameter-arguments object:

1. Parameters of the ECMAScript function:

The parameters of the ECMAScript function are internally represented by an array, which is always received by the function, regardless of the number of arguments contained in the array, or the data type of the parameter being passed in.

This parameter array can be accessed through the arguments object in the body of the function.

2. Questions about named parameters:

The named parameter in the ECMAScript function is only convenient, but is not required. In ECMAScript, the parser does not validate named parameters, but instead obtains the number of arguments by accessing the length property of the arguments object , and the arguments object is determined by the number of parameters passed in. is not determined by the number of named arguments when the function is defined.

3. Value synchronization:

The value of arguments is always synchronized with the values of the corresponding named parameters, but their memory space is independent. Named parameters that do not pass a value are automatically assigned the undefined value.

ps:<1> If only one parameter is passed in, the value of arguments[1] is not reflected in the named parameter.

All parameters in <2>ecmascript are passed as values, and arguments cannot be passed by reference.

JS Understanding Parameter-arguments 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.