It's called the Short-circuit evaluation and it's a feature of TypeScript. Not JavaScript .
When whatever before ? Is null or undefined, whatever after ?. Won't be called.
That's to avoid errors like: undefined has no property removeEventListener
Edit
I was wrong when I said it's not a feature of JavaScript. It's actually a new feature. Some browsers that are not updated to the latest don't support it yet (like mine)
Answer from TSR on Stack OverflowVideos
When should I use the ternary operator in JavaScript?
What is the syntax of the ternary operator in JavaScript?
Why is it called the ternary operator?
It's called the Short-circuit evaluation and it's a feature of TypeScript. Not JavaScript .
When whatever before ? Is null or undefined, whatever after ?. Won't be called.
That's to avoid errors like: undefined has no property removeEventListener
Edit
I was wrong when I said it's not a feature of JavaScript. It's actually a new feature. Some browsers that are not updated to the latest don't support it yet (like mine)
Optional chaining (?.) The optional chaining operator (?.) enables you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining