JavaScript-数组降维
Posted 我需要一杯水
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript-数组降维相关的知识,希望对你有一定的参考价值。
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-数组降维的主要内容,如果未能解决你的问题,请参考以下文章