类数组转换成数组的几种方法

1、Array.prototype.slice.call(arguments)
2、[].slice.call(arguments)
3、[...arguments]
4、Array.from(arguments)

要把类数组转换成数组的原因:

类数组缺少部分的数组API,比如: slice, forEach, map 等集合函数

猜你喜欢

转载自blog.csdn.net/weixin_41606276/article/details/105249794