Array array is equivalent to ArrayList in java
definition method:
1: Use new Array(5
) to create array var ary = new Array (5);
2: Use Json syntax, var ary = [1,3,4];
Array sorting:
Example:
function sort(){
var ary=[11,12,3,5,29];
ary.sort(); // Sort by character encoding 11,12,29,3,5;
alert( ary.toString());
ary.sort(function(v1,v2){
return v1-v2;//Custom sorting rules 3,5,11,12,29
});
alert(ary.toString());
}