对象无length属性时IE6/7中无法将其转换成伪数组(ArrayLike)
有时需要将数组转成伪数组(ArrayLike),如下
var ary = ['one','two','three'];var obj = {length:2}; // 有length,非零值Array.prototype.push.apply(obj, ary);for(var i in obj){alert(i + ': ' + obj[i]);}
?
相关:
将HTMLCollection/NodeList/伪数组转换成数组