On Wed, Mar 25, 2015 at 2:40 AM Robin Cafolla <[email protected]>
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
[email protected]
https://mail.mozilla.org/listinfo/es-discuss