The object property is used as a function parameter.

Source: Internet
Author: User

When a function has many parameters and assuming that the project has a large amount of work, the programmer must remember the nature and sequence of the function's parameter list accurately, this is difficult. In order to facilitate every call to a function, we do not need to repeatedly search for documents, we can allow parameters to be passed in any order by name/key value. I think this will save a lot of effort for our programmers.

To implement this method, we define the function parameters as objects. Then, we can expect users to pass an object that defines the required name/key value, this is easy to operate, saving us a lot of trouble or confusion.

1 function girl (a, B, c, d)
2 {
3 // code
4}
5 function boy (obj)
6 {
7 girl (obj. a, obj. B, obj. c, obj. d );
8 // code
9}
10 var Ellen = ["Ellen", 23, "mm", 54];
11 var home = new Array [4];
12 var mm = {a: Ellen; B: home; c: 1; d: 11 };

13 boy (mm );

This will streamline a lot of our work and improve our work efficiency.

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.