What does the optional chaining operator ?. do?
- A Throws an error if the value is null
- B Returns undefined instead of throwing when accessing a property of null or undefined
- C Provides a default value
- D Makes a property optional in a class
Answer
Returns undefined instead of throwing when accessing a property of null or undefined
obj?.a?.b short-circuits to undefined if any link is null or undefined, avoiding a TypeError. The ?? operator supplies a default value.





