Length Property (Function) (JavaScript)

Source: Internet
Author: User

Reprint: http://msdn.microsoft.com/zh-cn/library/4cz6db7d (v=vs.94). aspx

Gets the number of parameters defined for a function.

Functionname.length

Note

The necessary functionname is the name of the function.

When an instance of a function is created, the script engine initializes the function's length property to the number of arguments in the function definition.

When a function is called, if the number of its arguments differs from the value of its length property, the situation depends on the function.

Example

The following example illustrates the use of the length property:

1 functionArgtest (A, b) {2     vars = "";3 4s + = "expected Arguments:" +argtest.length;5s + = "<br/>";6s + = "Passed Arguments:" +arguments.length;7 8     returns;9 }Ten  Onedocument.write (Argtest (1, 2)); A  - //Output: - //expected Arguments:2 the //Passed Arguments:2

Requirements

Supported in the following document modes: Quirks, Internet Explorer 6 standard mode, Internet Explorer 7 Standard mode, Internet Explorer 8 standard mode, Internet Explorer 9 standard mode, INT Ernet Explorer 10 Standard mode and Internet Explorer 11 standard mode. In addition, it is also supported in store apps (Windows 8 and Windows Phone 8.1).

Length Property (Function) (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.