Refutable destructuring

Brandon Benvie bbenvie at mozilla.com
Fri Aug 9 16:21:00 PDT 2013


On 8/9/2013 4:03 PM, Allen Wirfs-Brock wrote:
> const MUST = () => {throw TypeError("Missing required parameter"};
>
> function foo (a=MUST(), b, c) {...}

But that doesn't work for:

```js
function foo({ a } = { a: MUST() }){}
foo({}); // doesn't throw

function bar({ +a }){}
bar({}); // would throw
```




More information about the es-discuss mailing list