伪数组转成真数组方法

159 阅读1分钟
伪数组转成真数组方法
    1)使用Array.prototype.slice.call(); 
    2)使用ES6中Array.from方法; 
    3)可以声明一个空数组,通过遍历伪数组把他们重新添加到新的数组中
    4)使用原型继承
         aLi.__proto__ = Array.prototype
         var aLi = document.querySelectorAll('li');
         console.log(aLi.constructor === Array) //false4
         aLi.__proto__ = Array.prototype;
         console.log(aLi.constructor === Array) //true