1. array declaration method
(1): arrayObj = new Array (); // create an Array
Var arr1 = new Array ();
(2): arrayObj = new Array ([size]) Create an Array and specify the length. Note that the length is not the upper limit.
Var a = new Array (5 );
(3): arrayObj = new Array ([element0 [, element1 [,... [, elementN]) Create an Array and assign values
Var a = new Array (["B", 2, "a", 4,]);
(4): arrayObj = [element0, element1,..., elementN]
Var a = ["B", 2, "a", 4,];
(Note): note the difference between "[]" and "[]".
Var a = new Array (5); // creates an Array of 5 characters.
Var a = new Array ([5]); // creates an Array with a length of 1 and a first value of 5.
2. Array Operation (Transfer address)
Var t2 = new Array (); t2 [0] = 1; t2 [1] = 2; test2 (t2); // transfer address (Array) function test2 (var2) {for (var I = 0; I <var2.length; I ++) {var2 [I] = var2 [I] + 1 ;}} for (var I = 0; I <t2.length; I ++) {alert (t2 [I]);}
Articles you may be interested in
- Js array to string, js string to array method summary
- Rational use of MySQL database indexes to make the database run efficiently
- JavaScript array operation function Summary (push, pop, join, shift, unshift, slice, splice, concat)
- PHP generates continuous numbers (letters) Array Function range () analysis, PHP lottery program function
- Php converts a multi-dimensional array to a one-dimensional array
- Js print array, js Print Object Method
- Php uses array_flip to implement array key-value exchange to remove array duplicate values
- Javascript restricts that only numbers (including decimal places) can be entered in the text box)