fail-fast object destructuring

Andreas Rossberg rossberg at
Wed Jul 11 04:16:25 PDT 2012

On 10 July 2012 10:47, Russell Leggett <russell.leggett at> wrote:

> Another thing that I was also thinking is that it might look a little
> nicer if the ? was a post-fix instead of a pre-fix.
>     let {first, last, company?} = contact;
> I might be missing why this wouldn't work out, but it aesthetically just
> looks right to me. It looks like the regex operator, and is also obviously
> the position it would be in english.

Even parsing issues aside, I don't like postfix better. It is easier to
miss, especially if ? was possible on patterns, not just properties.

  let {the, that: {x, y}, those, theirs: {what, why}, thus}? =

How easy is it to miss the final '?' when looking for the binding of 'x'?

But even on longish property names it can be a tad too easy to overlook:

  let {what, why, whatTheHeckIsGoingOn?} = callSomething()

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

More information about the es-discuss mailing list