<script type="text/javascript">
//方法一
var arr = [1,[2,3,[4,5,6],7]];
var arr = [1,[2,3,[4,5,6],7]];
var arr2 =arr.toString().split(",");
console.log(arr2);
//方法三
var arr = [1,[2,3,[4,5,6],7]];
var arr3 =[];
function foo(arr){
for(var i=0;i<arr.length;i++){
if(Array.isArray((arr[i]))){
foo(arr[i]);
}else{
arr3.push(arr[i]);
}
}
}
foo(arr);
console.log(arr3);
</script>
//方法一
var arr = [1,[2,3,[4,5,6],7]];
var arr1 =arr.join(",").split(",");
//注 :字符串数组 如果想转数值数组
arra1=[];
for(var j=1;j<arr1.length;j++){
arra1.push(Number(arr1[j]))
}
console.log(arr1);
console.log(arra1);
var arr = [1,[2,3,[4,5,6],7]];
var arr2 =arr.toString().split(",");
console.log(arr2);
//方法三
var arr = [1,[2,3,[4,5,6],7]];
var arr3 =[];
function foo(arr){
for(var i=0;i<arr.length;i++){
if(Array.isArray((arr[i]))){
foo(arr[i]);
}else{
arr3.push(arr[i]);
}
}
}
foo(arr);
console.log(arr3);
</script>