JavaScript Advanced Programming Chapter 5th Object Type---Array---learning experience

Source: Internet
Author: User

1. How to create an array:

    1. Use the array constructor:
    2. var colors=new  Array ()var colors=New Array (+)//  L Create an array of 20 items var colors=New Array ("Red", "Blue", "green")// Create an array with 3 strings 

2. Use the array literal to indicate:

var colors=["Red", "Blue", "green"]// Create an array with 3 strings var names=[]//  Create an empty array var values=[1,3,]// do not create an array with 2 items/3 items var options=[,,,,,]/ / Don't do this, create an array containing 5 items/6 items

2. The length property of the array: more than just readable, by setting this property, you can remove an item from the end of the array or add an item to the array.

3. Detecting Arrays:

For a single Web page, a global scope uses instance Of:if (value instanceof Array) {To perform certain operations on the array), and if the page contains more than one frame, there are actually more than two different global execution environments. Thus there are more than two different versions of the array constructor, using the Array.isarray () method of the ECMAScript 5 function, which supports the following browsers: Ie9+,firefox 4+,safari 5+,chrome, and so on.

JavaScript Advanced Programming 5th Chapter Object Type---Array---learning experience

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.