JS数组扁平化方法总结
距离上次更新已经过了 1092 文中部分内容可能已经过时,如有疑问,请在下方留言。
js
1 | let ary = [1, [2, [3, [4, 5]]], 6]; |
常用:
第一种:
js
1 | arr_flat = arr.flat(Infinity); |
第二种:扩展运算符
js
1 | while (ary.some(Array.isArray)) { |
第三种:
js
1 | ary = str.replace(/(\[\]))/g, '').split(','); |

Invitation
aqing
962555446
created:15/04/2021
Welcome to Candyhome
Use this card to join the candyhome and participate in a pleasant discussion together .
Welcome to aqing's candyhome,wish you a nice day .
评论