通过Slice进行转换1
var arr = Array.prototype.slice.call( htmlCollection )
通过Slice进行转换2
类似上面的方法
var arr = [].slice.call(htmlCollection);
利用Array.from ES6
Since ECMAScript 2015 there is also Array.from:
var arr = Array.from(htmlCollection);
利用类似Array.from缩写...
ECMAScript 2015 also provides the spread operator, 但Array.from支持map方法,而...不支持
var arr = [...htmlCollection];
网友评论