<!DOCTYPE?html>
<html>
<head>
<meta?charset="UTF-8">
<title>數組分割</title>
</head>
<body>
<div?id="test"></div>
</body>
</html>
<script?type="text/javascript">
var?str='廣東省,深圳市,龍華新區,金龍路,逸秀新村華富錦大廈';
//split()方法將字符串分割為字符串數組,并返回此數組。
//知識鏈接??http://www.xianlaiwan.cn/code/832
var?ary=str.split(",");
console.log(ary[0]);
console.log(ary[1]);
console.log(ary[2]);
console.log(ary[3]);
console.log(ary[4]);
//join()把數組的所有元素放入一個字符串。元素通過指定的分割符進行分割。
//知識鏈接??http://www.xianlaiwan.cn/code/873
console.log(ary.join("?"));
//賦值
var?test=document.getElementById('test');
test.innerHTML=ary.join("?");
</script>