问答详情
源自:7-22 数组排序sort()

例题里的数字排序

1.使用sort()将数组进行排序,代码如下:

<script type="text/javascript">
 var myarr1 = new Array("Hello","John","love","JavaScript");
 var myarr2 = new Array("80","16","50","6","100","1");
 document.write(myarr1.sort()+"<br>");
 document.write(myarr2.sort());
</script>

运行结果:

Hello,JavaScript,John,love
1,100,16,50,6,80

本节里的例题数字排序为什么是这样,求解。

提问者:贝小加 2016-03-01 10:20

个回答