Corey Frang (2013-11-11T19:31:40.000Z)
I hate to bring this up, as I'm sure I've missed a bunch of the arguments
that define WHY, but if this is the case, it seems unintuitive to me that
passing undefined still results in a default param being set.


function test(a = 1) { console.log(a); }

test(); // gets 1 - yay
test(undefined); // gets 1 - boo! Expect: undefined

(sorry tab, forgot to reply all on the first reply :( )


On Mon, Nov 11, 2013 at 12:37 PM, Tab Atkins Jr. <jackalmage at gmail.com>wrote:

> On Mon, Nov 11, 2013 at 9:21 AM, Allen Wirfs-Brock
> <allen at wirfs-brock.com> wrote:
> > On Nov 11, 2013, at 6:10 AM, Mark S. Miller wrote:
> >> On Sun, Nov 10, 2013 at 11:33 PM, Corey Frang <gnarf37 at gmail.com>
> wrote:
> >>> Just to provide another way of working around it:
> >>>
> >>> var empty = {}; // or even a symbol?
> >>>
> >>> function splice(start = empty, count = 0, ...items) {
> >>>   if (start === empty) { ...
> >>> }
> >>
> >> That is excellent! Has all the upsides of the best of the other
> proposals
> >> and none of the downsides.
> >
> > No, this doesn't work because then both
> >      [1,2,3].splice()
> >      [1.2.3].splice(undefined)
> >
> > will both result in start === empty.  But for web compatibility they
> must be
> > treated differently.
>
> Right.  The one and only way to test for missing args different from
> undefined is to use a rest arg and test length, as demonstrated
> earlier in this thread.
>
> ~TJ
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131111/2a2dea3f/attachment.html>
domenic at domenicdenicola.com (2013-11-15T18:55:53.507Z)
I hate to bring this up, as I'm sure I've missed a bunch of the arguments
that define WHY, but if this is the case, it seems unintuitive to me that
passing undefined still results in a default param being set.

```js
function test(a = 1) { console.log(a); }

test(); // gets 1 - yay
test(undefined); // gets 1 - boo! Expect: undefined
```