es6-rest
es6-rest
by 郭 凡
JavaScript
function say(a,b,...rest) {
console.dir(arguments);
console.dir(rest);
}
say(1,2,3,4,5,6);
//模仿剩余参数
function f(a, b){
var args = Array.prototype.slice.call(arguments, f.length);
// ...
}
// 现在代码可以简化为这样了
function(a, b, ...args) {
}