数组扁平化的方法

1 console.log(
2   [1, [2, 3, [4, 5]]]
3     .toString()
4     .split(",")
5     .map((item) => +item)
6 ); 
7 //[ 1, 2, 3, 4, 5 ]

通过
[1, [2, 3, [4, 5]]].flat(Infinity)

实质:
Array.prototype.flat = function() { return this.toString().split(',').map(item => +item ) }
原文地址:https://www.cnblogs.com/ndh074512/p/15226958.html