Refutable matching and default values
# Andreas Rossberg (13 years ago)
On 28 February 2013 04:06, Axel Rauschmayer <axel at rauschma.de> wrote:
Question: Does a
Pattern "=" AssignmentExpressionmake 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).
harmony:refutable_matching
Question: Does a
make sense without a prefixed question mark? For example, what would the result of the following statement be?
Thanks!
Axel
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} = {}; Thanks! Axel -- Dr. Axel Rauschmayer axel at rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130228/540a5aa5/attachment.html>