Javascript real parameter object arguments

Source: Internet
Author: User

In the function body, the identifier arguments is an application that points to the real parameter object, and the real parameter object is an array object, so that you can access the real parameter value of the input function through the numerical subscript,

Demonstrate arguments usage

View code

// Query the maximum function Maxs () {VaR _ max = number. negative_infinity; // negative infinity. This value is returned when overflow occurs. // The system traverses the real parameters and searches for and records the maximum value for (VAR I = 0; I <arguments. length; I ++) {If (arguments [I]> _ max) {_ max = arguments [I] ;}return _ max ;}var largest = Maxs, 4,10, 3,0, 33,44); console. log (largest); console. log ("************************************* ********************************"); function f (x) {console. log (x); arguments [0] = NULL; console. log (x); console. log ("arguments length:" + arguments. length); // actual parameter console. log ("Expected parameter count:" + arguments. callee. length);} f (1 );

The most suitable application scenario for argument [] objects is when a function contains a fixed number of required parameters for naming, and optional parameters with a variable number. Arguments is not a real array.

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.