Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Active reading [<https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_%E2%80%93_ECMAScript_2019>].
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

ES2019ECMAScript 10 introduced a new feature - optional chaining which you can use to use a property of an object only when an object is defined like this:

const userPhone = user?.contactDetails?.phone;

It will reference to the phone property only when user and contactDetails are defined.

Ref. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

ES2019 introduced a new feature - optional chaining which you can use to use a property of an object only when an object is defined like this:

const userPhone = user?.contactDetails?.phone;

It will reference to phone property only when user and contactDetails are defined.

Ref. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

ECMAScript 10 introduced a new feature - optional chaining which you can use to use a property of an object only when an object is defined like this:

const userPhone = user?.contactDetails?.phone;

It will reference to the phone property only when user and contactDetails are defined.

Ref. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

Source Link

ES2019 introduced a new feature - optional chaining which you can use to use a property of an object only when an object is defined like this:

const userPhone = user?.contactDetails?.phone;

It will reference to phone property only when user and contactDetails are defined.

Ref. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

lang-js

AltStyle によって変換されたページ (->オリジナル) /