Refutable matching and default values
Andreas Rossberg
rossberg at google.com
Thu Feb 28 00:32:46 PST 2013
On 28 February 2013 04:06, Axel Rauschmayer <axel at rauschma.de> wrote:
> http://wiki.ecmascript.org/doku.php?id=harmony:refutable_matching
>
> Question: Does a
>
> Pattern "=" AssignmentExpression
>
> make sense without a prefixed question mark? For example, what would the
> result of the following statement be?
>
> let {a: x = 1} = {};
Yes, see the runtime semantics: if x is set to undefined. For example:
let {a: x = 1} = {a: undefined}
print(x) // 1
Not saying that this is a particularly useful corner case, but it is
in line with the semantics for function default arguments (which
should be a special case of pattern matching).
/Andreas
More information about the es-discuss
mailing list