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

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

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

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章