伪数组:是对象,可以按索引查找数据,有length属性。
- //Array.prototype.slice.call()
- const lis = document.getElementsByTagName('li')
- const lis2 = Array.prototype.slice.call(lis)//call:让一个函数成为指定对象的方法进行调用
-
- //Array.from()
- const lis3 = Array.from(lis)
-
- //三点运算符
- const lis3 = [...lis]