var arr = [2,34,242,12,3,2,23,3];// 定义一个数组arr.sort(function (a,b) {// a -->代表每一次执行匿名函时候,找到的数组中的当前项;// b -->代表当前项的后一项;return a - b; // 升序时: 如果a>b,那么返回的值>0,a和b交换位置;return b - a; // 降序时:
看高性能javascipt 这本书时,看到这么一句话:Putting scripts at the top of the page in this way typically leads to a noticeable delay, often in the form of a blank white page, before the user can even begin reading or o