Hi,

In Firefox 74, we'll ship the optional chaining operator.

*Bug: *https://bugzilla.mozilla.org/show_bug.cgi?id=1566143
*Standard: *https://tc39.es/proposal-optional-chaining/
*Platform coverage: *All, no pref
*DevTools bug: *N/A.
*Other browsers:* Shipping in Chrome, Shipping in Safari
*Testing: *
https://github.com/tc39/test262/tree/master/test/language/expressions/optional-chaining
<https://github.com/tc39/test262/tree/master/test/language/expressions/coalesce>

*Use cases: *Optional chaining may be useful in cases where a property may
be conditionally present. This affects property access, dynamic property
access, and function calls in the following way:

*Property access*

Before
const street = user.address && user.address.street;

After
const street = user.address?.street;

*Dynamic Property Access*
Before
const street = user.address && user.address["street"];

After
const street = user.address?.["street"];

*Optional function calls:*

Before
const result = myObj.method && myObj.method();

After
const result = myObj?.method();


*Secure contexts:* This is a JS language feature and is therefore present
in all contexts.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to