Interesting array of programming -JavaScript-

What is an array it? Array is worth an ordered set . Each value is called an element, and each element has a location in the array, expressed as a number, called an index.
In JavaScript array has the following characteristics:

  1. Untyped array elements which may be of any type. (May even be an array of arrays of objects or arrays of other arrays, array ..........................................)
  2. The first element is indexed: 0, last element index is: 4294967294.
  3. Dynamic: the need to increase or reduce the array based on, so when you create an array of size would not declare a fixed-length.
  4. It may be discontinuous (sparse): space in the array may be vacant.

How to create an array of it?

  1. An array of direct amount
    var array=[1,"a","叶",true,1.1];
  2. Calling Array constructor:
    var a=new Array();//创建一个空数组
    var b=new Array(10);//创建一个长度为10的数组
    var c=new Array(1,"a","叶",true,1.1);//创建一个存放这些元素数组

Read array

var a=["codemax"];//写入第一个元素
alert(a[0]);//读取第一个元素,数组下标为0
a[1]=66666666;//写入第二个元素,很6
var i=2;//下面几句代码输出的结果是?
a[i]=3;
a[i+1]="Hello World !";
alert(a[a[i]]);

Deepen the understanding of the array of knowledge through the following points

  1. In fact, the array is a special form of objects.
  2. Sparse array
  3. Length of the array
  4. Add and delete arrays
  5. Iterate
  6. Multidimensional Arrays
  7. An array of methods
  8. Method of array ECMAScript5
  9. Array type
  10. Class array of objects
  11. As the array of strings

References - "JavaScript The Definitive Guide"
Write pictures described here

Guess you like

Origin blog.csdn.net/dreamer_sen/article/details/76735630