关于Arguments对象

2018-04-10  本文已影响0人  Gaarahan

The arguments object is an Array-like object corresponding to the arguments passed to a function.

The arguments object is not an Array. It is similar to an Array, but does not have any Array properties except length. For example, it does not have the popmethod. However it can be converted to a real Array:

----MDN

var args = Array.prototype.slice.call(arguments);
var args = [].slice.call(arguments);

// ES2015 
//The Array.from() method creates a new Array instance
// from an array-like or iterable object.
const args = Array.from(arguments);
上一篇 下一篇

猜你喜欢

热点阅读