A. Define an array:
Method 1
var mycars=new Array (); mycars[0]= "Saab"; Mycars[1]= "Volvo"; mycars[2]= "BMW";
Method 2:
var mycars=new Array ("Saab", "Volvo", "BMW");
Method 3.
var mycars=["Saab", "Volvo", "BMW"];
Two. Array modification using for loop traversal
① in the array to specify the worthy location
var x=mycars.length //Array length Y=mycars.indexof ("Volvo") //a worthy location
② merging Arrays concat ()
var hege = ["Cecilie", "Lone"];var stale = ["Emil", "Tobias", "Linus"];var children = hege.concat (stale);
③ Array to string ToString () or join () "Join can arbitrarily set the interval character ToString no"
var fruits = ["Banana", "Orange", "Apple", "Mango"];var t =fruits.join ("--");
Results: Banana--orange--apple--mango
④:slice ()//The original array did not change
var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];var citrus = fruits.slice (1,3),//1 is the length of index 3
Results: Orange,lemon
⑤:splice ()//change the original array directly
var fruits = ["Banana", "Orange", "Apple", "Mango"];fruits.splice (2,0, "Lemon", "Kiwi"), change the original array directly
Results: Banana,orange,lemon,kiwi,apple,mango
JS array processing