[TOC]

方法名 说明 是否修改原数组

reverse() 颠倒数组中元素的顺序,无参数 该方法会改变原来的数组,返回新数组
sort() 对数组的元素进行排序 该方法会改变原来的数组,返回新数组
sort()方法是使用的冒泡和插入两种方式结合进行排序的。
原理解析见百度:https://www.jianshu.com/p/bcb6a8f4c114

注意:sort到了两位数以上就不行了
完美写法:arr.sort(function(a,b){
return a-b;//升序
return b-a;//降序
return Math.random() > .5 ? -1 : 1//随机排序(拓展)
})

(9) [14, 16, 23, 47, 51, 59, 62, 65, 78]

(9) [78, 65, 62, 59, 51, 47, 23, 16, 14]

.