// 100以内的质数 // let count; // for (let i = 2; i <= 100; i++) { // for (let j = 1; j <= i; j++) { // if (i % j === 0) { // count++ // } // } // if (count == 2) { // console.log(i) // } // count = 0 // } // 多维数组变为一维数组 let arr=[1,2,3,[4,5,6,[7,8,9,[10,11,12]]],13,14,[15,16]] // let newarr=Object.values(arr).flat(Infinity) const newarr=function(arr){ return [].concat(...arr.map(t=>(Array.isArray(t)?newarr(t):t))) } console.log(newarr(arr))