Iterating default function arguments

Axel Rauschmayer axel at
Wed Mar 25 17:12:42 UTC 2015

> I'm all for using Reflect, but looking at the API as listed on MDN, the harmony-reflect github, or the spec, i don't see an obvious way of getting the parameters.

If I understand you correctly (and this is not about parsing the parameter definitions) then how about the following solution?

function foo(…args) {
    let [a, b = 2] = args;
    return args;

Original code:

function foo( a, b = 2 ) {
    return arguments;

Dr. Axel Rauschmayer
axel at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list