判断对象是Array还是Object
1.obj instanceOf Array;
在不同 iframe 中创建的 Array 并不共享 prototype
![](https://img.haomeiwen.com/i9930333/cccdee8ba8fd4083.png)
2.obj.constructor==Array;
3.Array.isArray(obj);
4.Array.prototype.isPrototypeOf(obj);
5.Object.prototype.toString.call(obj);
![](https://img.haomeiwen.com/i9930333/bf3cf21c1dc9490a.png)
将类数组对象转化为数组
1.Array.from(obj);
2.Array.prototype.splice.call(obj,0);
3.Array.prototype.concat.apply([],obj);
![](https://img.haomeiwen.com/i9930333/435f3b91015d32ea.png)
4.Array.prototype.slice.call(obj);||[].slice.call(obj);
5.Array.apply(null,obj);
试着编写一个 arrayMerge() 函数,实现该函数被调用时,传递任意数量的数组,返回一个合并后的数组(可不局限于一种实现)。
![](https://img.haomeiwen.com/i9930333/c75ded41d3673d7a.png)
Fragment
![](https://img.haomeiwen.com/i9930333/da4d69545fbaf8d0.png)
![](https://img.haomeiwen.com/i9930333/bec09d0d7abe3ace.png)
![](https://img.haomeiwen.com/i9930333/0ca79013ceef5e42.png)
网友评论