<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<script type="text/javascript">
var str="[";
arr2=[1,2,3];
function dis(arr){
for(int i=0;i<arr.length;i++){
if(arr[i]!=arr[arr.length-1]){
str+=arr[i]+",";
}
else{
str+=arr[i]+"]";
}
}
document.write(str);
}
dis(arr2);
</script>
</body>
</html>
3 回答
慕少森
TA贡献2019条经验 获得超9个赞
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<script type="text/javascript">
arr2=[1,2,3];
document.write("["+arr2.join(",")+"]");
</script>
</body>
</html>
添加回答
举报
0/150
提交
取消