Objects and arrays-multiple ways to create arrays

Source: Internet
Author: User

——————————————————————————

<script type= "Text/javascript" >
Use the Array object's constructor array (), array object, which is a built-in object, and also provides a parameter that represents the initial length of the array
var arr001 = new Array (); Use the new statement to create an array of length 0
Arr001[0] = 1; The first element is a 1
ARR001[1] = 2; The second element is a 2
ARR001[2] = 3; The third element is a 3
Alert (' The value of the second element is: ' + arr001[1]);//subscript starting from 0
Create an array using the brackets
var arr002 = []; Use grand brackets to create, or initialize some data
Arr002[0] = ' a '; The first element is a
Arr002[1] = ' B '; The first element is a B
ARR002[2] = ' C '; The first element is a C
Alert (' The length of the array: ' + arr002.length ');//The length of the array can be dynamically increased
</script>

————————————————————————————

Objects and arrays-multiple ways to create arrays

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.