类数组转为真正数组的方法


类数组

具有length属性的对象,比如
var arrayLike={
name:'lizzy',
age:21,
length:30
}

类数组转为真正数组的方法

1.slice方法
const arr = Array.prototype.slice.call(arrayLike);

2.Array.from方法
Array.from(arrayLike);

3.用拓展运算符...,前提是这个类数组对象上部署了遍历器接口。arguments满足条件

function demo(){
	console.log(...arguments)
}
demo(1,2,3,4)