} = x?.;
Isn't this already implemented as Nullish coalescing operator (??)
You need a default value then, like x ?? {}; What if you want to deeply destructure?
You may have meant to link this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
can you give an example of deeply destructuring
const { a, b, p: { q, r } } = x?.;
This is a strange syntax though, not even kotlin has anything like this. also the dot at the end could be misinterpreted as part of the destructuring remember js doesn't enforce semi colons and can be put on one line
You can write this today and have a syntax error: x.
The JS parser would know we're in a destructuring context, and expect the expression to end with an identifier or optional access
what if you want to destructure an optionally chained object
Обсуждают сегодня