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());
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn