The optional chaining operator in JavaScript is convenient as it allows the developer to specify an object’s property as being optional, and only return a value if the specified property is not “null” or “undefined” - otherwise return “undefined”.
It’s helpful when accessing data from an API, or generally where you’re not too sure what data will look like, or knowing where optional fields exist. It can also be used in combination with the nullish coalescing operator to provide smart defaults 🙂
For your reference, check this out:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
#javascript