Array.of
作者:互联网
Array.of
- 如果要实现一个将方法参数arguments变成数组的功能,你会怎么实现?
Array.prototype.slice.call(arguments)
- Array.of
Array.of(1, 2, 3); // [1, 2, 3]
- 如果原生不支持,我们可以使用如下代码
if (!Array.of) {
Array.of = function() {
return Array.prototype.slice.call(arguments);
};
}
标签:slice,MDN,call,arguments,Array,prototype 来源: https://www.cnblogs.com/mengxiangzhi/p/16252568.html