Похожие чаты

Today: Const a = x?.a; const b = x?.b; Tomorrow?.: const { a, b

} = x?.;

9 ответов

9 просмотров

Isn't this already implemented as Nullish coalescing operator (??)

Richard | Dm for Paid Support
Isn't this already implemented as Nullish coalesci...

You need a default value then, like x ?? {}; What if you want to deeply destructure?

Richard | Dm for Paid Support
Isn't this already implemented as Nullish coalesci...

You may have meant to link this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

MUTHU・KUMAR 「メーカー」 🔺
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

The JS parser would know we're in a destructuring context, and expect the expression to end with an identifier or optional access

Похожие вопросы

Обсуждают сегодня

Карта сайта