Refutable destructuring

Brandon Benvie bbenvie at mozilla.com
Fri Aug 16 14:01:30 PDT 2013


On 8/16/2013 12:56 PM, Allen Wirfs-Brock wrote:
> However, I think throwing is like to reveal bugs that might otherwise 
> be missed prior to deployment and as a code reader I would prefer to 
> encounter
>    let {x=undefined) = {};
> which communicates much more clearly that there is an expectation that 
> 'x' may not exist as a property of the RHS.

I think this is true of assignment/declaration destructuring, but untrue 
for parameter destructuring. I think a very common use case for 
parameter destructuring is optional values in an options object. Given 
that we want assignment destructuring and parameter destructuring to be 
the same thing, I think that we have to allow soft-fail.


More information about the es-discuss mailing list