码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript-数组降维

时间:2020-03-12 12:50:17      阅读:47      评论:0      收藏:0      [点我收藏+]

标签:his   i++   this   class   asc   span   java   var   bsp   

    
    var thisArr = function(arr) {
        var new_arr = [];
        for(var i = 0; i < arr.length; i++){
            if(Array.isArray(arr[i])){
                thisArr(arr[i]);
            }else{
                new_arr.push(arr[i]);
            }
        }
    };
        
    function ladding(){
        var arr = [1,2,3,4,5,["a","b","c","d","e",["A","B","C","D","E",["FIRST","SECOND","THIRED","FOURED","FIRED"]]]];
        thisArr(arr);
        console.log(new_arr);
    }

 

JavaScript-数组降维

标签:his   i++   this   class   asc   span   java   var   bsp   

原文地址:https://www.cnblogs.com/tanjiyuan/p/12468368.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!