1 var arrN = [[[1, "wangyuchu", 54, [123, 34, [123, 34, 16]]],"zhangsan", 25, [1, "wangyuchu", 54, [123, 34, [123, 34, [1, "wangyuchu", 54, [123, 34, [123, 34, 16]]],]]], 43], ["lisi", 21, 172], ["wangwu", 32, "suzhou"]]; 2 3 var arrgroup=[]; 4 function recursion(obj) { 5 if (typeof obj===‘object‘) { 6 for (var j in obj) { 7 if (typeof obj[j]!==‘object‘) { 8 arrgroup.push(obj[j]); 9 continue; 10 } 11 recursion(obj[j]); 12 } 13 } else { 14 arrgroup.push(obj); 15 } 16 return arrgroup; 17 } 18 console.log(recursion(arrN));
时间: 2024-10-21 03:11:09