One:arguments Object Pseudo-array

Source: Internet
Author: User

This is my first blog.

1<script>2         //calculates the and of n numbers3         //define a function, if you are not sure whether the user passed the parameter, or do not know that the user passed a few parameters, no way to calculate,4         //But if you know the number of arguments in a function, and you know the value of each parameter, you can5         //definition6         functionF1 () {7             //arguments.length: Gets a function that passes in a few arguments when called8             //arguments: Gets the value of each parameter passed in;9             //Console.log (arguments.length);Ten console.log (arguments); One  A         } -F1 (10,20,30,40,50);//called -  the         functionF2 () { -             //pseudo array using arguments -             varSum=0; -              for(vari=0;i<arguments.length;i++) +             { -sum+=Arguments[i]; +             } A             returnsum; at         } -Console.log (F2 (10,20,30)); -  -</script>

One:arguments Object Pseudo-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.