I think the main concern was: > Currently I can't see a way of getting default parameters as an iterable object.
and indeed `arguments` is not the magic variable you are looking for. However, you are inside your own defined function so either you don't specify defaults, or you iterate over `[a, b]` ? Interesting enough, there's no actually a way to understand the function signature, in terms of optionally accepted arguments. `arguments.length` is one and same is for `foo.length` so if we'd like to understand if anyone invoked the function passing or not all optional parameters, how could we proceed? Lets say `foo` would like to delegate its own arguments including defined defaults to another function ... how can we grab these at runtime? I think the answer is still a static `[a, b]` as list of arguments to apply, but I can see some lack of "reflection" capability ... or maybe Reflect would solve this? Regards On Wed, Mar 25, 2015 at 4:56 PM, Rick Waldron <waldron.r...@gmail.com> wrote: > > > On Wed, Mar 25, 2015 at 2:40 AM Robin Cafolla <ro...@zombiemongoose.com> > wrote: > >> Hi there, >> >> I was wondering if there were any plans to modify `arguments` to include >> default parameters (e.g. changing it from a simpleParameterList) or to >> include a new property that does allow iteration of all values available to >> a function. >> >> for example: >> >> function foo( a, b = 2 ) { >> return arguments; >> } >> >> console.log( foo( 1 ) ); // outputs [ 1 ], not [ 1, 2 ] >> >> Currently I can't see a way of getting default parameters as an iterable >> object. >> >> I filed a bug with Mozilla over this, but they pointed out that the >> behaviour matches the spec. >> >> https://bugzilla.mozilla.org/show_bug.cgi?id=1144672 >> > > > This is correct, because only one _argument_ was passed, therefore the > arguments object has only one entry. Parameters are not the same as > Arguments. > > Therefore: > > foo(1, 3) => [1, 3] > > Because two arguments were passed. And: > > foo(1, 2, 3) => [1, 2, 3] > > Because three were passed. > > Hopefully that helps clarify? > > Rick > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss