JS数组扁平化方法总结
1 | let ary = [1, [2, [3, [4, 5]]], 6]; |
常用:
第一种:
1 | arr_flat = arr.flat(Infinity); |
第二种:扩展运算符
1 | while (ary.some(Array.isArray)) { |
第三种:
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 .
评论