JavaScript several rent

Source: Internet
Author: User

a , how to create an array

(1) created by the object's way.

var a=new Array ();

A. Direct Assignment

var a=new Array ( element 1, Element 2, Element 3, Element 4,........)

var a=new Array ( numeric )

If there is only one element, and this element is a numeric type, then he is the length of the specified array.

And his values are undefined .

Properties of the array : Length Property

B. declaring a later assignment

var a=new Array ();

A[0]=1;

a[2]=2;

a[0]=3;

(2) the way of stealth declaration

var a=[];

A. Direct Assignment :

var a=[1,2,3,4];

B. declaring a later assignment

var a=[];

A[0]=1;

a[1]=2;

a[2]=3;

J the Avascript array can store values of any type.

Second, accessing elements of an array

Accessed through an array of ( brackets ) subscript .

Third, iterate over the elements of the array

(1) for Loop

(2) while ();

(3) for in

Iv. Classification of arrays:

1. type of subscript

A. Subscript is the type of the number ( indexed array )

B. The subscript is a string type ( associative array )

2. dimensions to classify

A. one-dimensional arrays

B. two-dimensional arrays

Declare a two-dimensional array :

var arr=[[1,2,3],[4,5,6]];


This article is from the "Mr.zhu-Technology Exchange" blog, please be sure to keep this source http://bjishu.blog.51cto.com/7481301/1671812

JavaScript several rent

Related Article

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.