js 数组降维

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-02 15:16  fxxk院子  阅读(58)  评论(0)    收藏  举报

导航