<!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>
<!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>
var arr2String = `[${arr2.toString()}]`;
document.write(arr2String);
'['+arr2.toString()+']'