Summary
The optional chaining (?.) operator can be used after bracket notation to access an object's property or call a function. If the object accessed or function called is undefined or null, the expression short circuits and evaluates to undefined instead of throwing an error, as stated in the MDN documentation.
1
This behavior is supported by the ECMAScript 6 specification.
According to
See more results on Neeva
Summaries from the best pages on the web
The optional chaining ?. syntax has three forms: obj?.prop – returns obj.prop if obj exists, otherwise undefined. obj?. [prop] – returns obj [prop] if obj exists, otherwise undefined. obj.method?. ()…
Optional chaining - JavaScript
javascript.info
Optional Chaining Example. Let’s first define an user object with some nested properties that we’ll try to test certain retrieval processes upon: const user = { personalDetails: { name: 'Tommy',…
Optional Chaining in React - Upmostly
upmostly.com
The ability to create JavaScript objects using literal notation is powerful. New features introduced from ES2015 ( ES6 ) make object handling even easier in all modern browsers (not IE) and Node.js.
ES6 in Action: Enhanced Object Literals — SitePoint
sitepoint.com