Home >Web Front-end >JS Tutorial >Commonly used methods for arrays in js
This article mainly shares with you the commonly used methods of arrays in js, hoping to help everyone.
arage.sort() is used directly and the default is ascending order.
Please note that
This only shows that sort can only Recognizing the first unicode character at the beginning still cannot perform ascending order operations
For true ascending order, you must use another form of sort
arage.sort(function(x,y){
return x-y;
})
The real descending order is just to reverse x and y and subtract them It’s
arrage.sort(function(x.y ){ return y-x; })
concat This is the fusion of arrays, an array of two people--and an array of 4
Related recommendations:
js Array functions and precautions
The above is the detailed content of Commonly used methods for arrays in js. For more information, please follow other related articles on the PHP Chinese website!