类数组对象
1 .拥有length属性,其他属性为非负数,对象中的索引会被当作字符串来处理
2 .不具有数组所具有的方法
3 .js种常见的类数组有arguments对象和DOM方法的返回结果,document.getElementByTagName()
4 .
function isArrayLike(o) {
if (o && // o is not null, undefined, etc.
typeof o === 'object' && // o is an object
isFinite(o.length) && // o.length is a finite number
o.length >= 0 && // o.length is non-negative
o.length===Math.floor(o.length) && // o.length is an integer
o.length < 4294967296) // o.length < 2^32
return true; // Then o is array-like
else
return false; // Otherwise it is not
}
5 .区别数组和类数组 isArray()
类数组转化为数组
1 .[...]
2 .Array.prototype.slice.call(arrayLike)
3 .转换为数组之后就能调用数组的一系列方法
4 .