arguments so we can deprecate, obsolete, and some years hence burn with fire / salt the earth anything to do with arguments, foo.arguments, etc.... as an optional prefix before the last formal parameter in a function declaration... in function foo(...rest) {...} creates a rest parameter, rest, denoting a new Array created when foo is called, whose elements from 0 to foo.length are supplied by the actual arguments passed to foo (if any)function bar(baz, bletch, ...rest) {...}, with elements of rest being supplied by the third through last actual parameters
// Trivial this-free wrapper around Function.prototype.apply:
function simpleApply(func, ...args) {
"use strict";
return func.apply(undefined, args);
}
// Simple printf-style string formatter, write and convert left as exercises:
function printf(format, ...args) {
var n = 0;
var i = 0, j;
while ((j = format.indexOf('%', i)) >= 0) {
if (n >= args.length)
throw "printf: too few args for given format " + format;
write(format.slice(i, j));
// convert takes exactly one format-specifier char, to keep things simple.
write(convert(s[j + 1], args[n++]));
i = j + 2;
}
write(format.slice(i));
}
... with no formal parameter identifier after it? Not without types or arity checks.— Brendan Eich 2009/05/04 22:52