Skip to content

Commit

Permalink
Create 多层数组扁平化.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Rain120 authored Aug 16, 2018
1 parent 58f2215 commit 5e014ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions 多层数组扁平化.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function flat(arr) {
return arr.toString().split(',').map(item => +item);
}
var arr = [[2],[[1,[2,3],2,5],[1],[2]],3,4];
flat(arr) // [2, 1, 2, 3, 2, 5, 1, 2, 3, 4]

0 comments on commit 5e014ba

Please sign in to comment.