destructuring: as patterns?

Brendan Eich brendan at
Fri Apr 20 14:37:34 PDT 2012

Brendan Eich wrote:
> Should
>   let {?x:{y}} = {};

I lost a line finishing the obvious "Should ... throw?" question.

We could make ? shallow and require another ?-prefix to avoid the throw:

   let {?x:{?y}} = {}

but that seems like it might be user-hostile.

CoffeeScript has ?. and ?( fail-soft operators which are quite popular. 
We talked about them last over a year ago, IIRC. Not proposing them here 
but citing them as nearby, and noting that CoffeeScript does require a 
?. per level:

coffee> a = {}
coffee> a.?b
Error: In repl, Parse error on line 1: Unexpected '?'
coffee> a?.b
coffee> a?.b.c
TypeError: Cannot read property 'c' of undefined
coffee> a?.b?.c


More information about the es-discuss mailing list