慕容8154426
2017-10-02 10:39
<script type="text/javascript">
function sortNum(a,b) {
return 0;//输出结果为:80,16,50,6,100,1
return a=b;//输出结果为:1,100,6,50,16,80
}
var myarr = new Array("80","16","50","6","100","1");
document.write(myarr.sort(sortNum));
</script>
从结果上看:return 0;数组排序不变;
return a=b;数组反转
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题