用数组的元素组成字符串 - join()

使用 join() 方法将数组的所有元素组成一个字符串。

 

编辑您的代码:

<html>

<body>

<script type="text/javascript">

var arr = new Array(3);

arr[0] = "George"

arr[1] = "John"

arr[2] = "Thomas"

document.write(arr.join());

document.write("<br />");

document.write(arr.join("."));

</script>

</body>

</html>

 

查看结果:

      George,John,Thomas
      George.John.Thomas

 

posted @ 2015-01-13 17:33  紫发少年  阅读(350)  评论(0编辑  收藏  举报