[JavaScript] named parameters and arguments

Source: Internet
Author: User
Tags function definition

The function in JavaScript does not restrict parameters and checks:

function does not mind how many parameters are passed in, or what type of arguments are passed in (even if the number of arguments is inconsistent with the definition of function).

The parameters in the function are internally saved by the arguments, which is an "array" (in fact, just like an array), which can be obtained by means of subscript access to the parameters of the passed function.

Arguments.lenght can get the number of arguments to the function passed in.

function Test () {    //  0//  1//  2

Named parameters in a function definition are only convenient, but are not required.

The named parameters remain in sync with the elements in the corresponding arguments:

function Test (ARG) {    arguments[0] + = ten;    Alert (ARG);} Test (//  

If a parameter is defined in function, but no value is passed to the parameter, the parameter is automatically assigned the undefined value.

[JavaScript] named parameters and arguments

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.