标签:
使用 sort() 方法从字面上对数组进行排序。
编辑您的代码:
<html>
<body>
<script type="text/javascript">
var arr = new Array(6)
arr[0] = "George"
arr[1] = "John"
arr[2] = "Thomas"
arr[3] = "James"
arr[4] = "Adrew"
arr[5] = "Martin"
document.write(arr + "<br />")
document.write(arr.sort())
</script>
</body>
</html>
查看结果:
George,John,Thomas,James,Adrew,Martin
Adrew,George,James,John,Martin,Thomas
标签:
原文地址:http://www.cnblogs.com/zifashaonian10000/p/4221918.html