js函数排序的实例代码
代码如下:var as = [1,2,11,3434,3,4545,33,55,0];as.sort(); //这个排序是按照字典排序//自定义按照数字排序function sortByNum(a,b){return parseInt(a) – parseInt(b);}as.sort(sortByNum);//按照对象来排序//定义一个person对象function Person(name.age){this.name=name;this.age=age;}var p1 = new Person(“zhang1”,11);var p2 = new Person(“zhang2”,1);va
用户评论