数组降维

let result = []
function ok(arr) {
   arr.forEach(function (item) {
        if (Object.prototype.toString.call(item)==="[object Array]") {
            ok(item)
        }else {
            result.push(item)
        }
    })
}
ok(['sdfsdf','6666666666',[1,[2,[555]]]])
console.log(result)

posted on 2019-07-03 14:04  fxxk院子  阅读(36)  评论(0)    收藏  举报

导航