2013年8月3日 星期六

javascript array sort javascript-array define

<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> 

Answer
George,John,Thomas,James,Adrew,Martin
Adrew,George,James,John,Martin,Thomas

沒有留言:

張貼留言