<script type="text/javascript"> function sortNum(a,b) { return a - b; //升序,如降序,把“a - b”该成“b - a” } var myarr = new Array("80","16","50","6","100","1"); document.write(myarr + "<br>"); document.write(myarr.sort(sortNum)); </script>
不带括号的调用 function : 函数体对象为参数
带括号的调用 function():立即执行函数后返回的值为参数
https://blog.csdn.net/yyx19941129/article/details/49642515 转自CSDN