I'm working on some javascript legacy code and I came across this conditional, can anyone tell me what does the '?' do? The 'items' property is not part of the currentItem object and it never is...
if (currentItem?.items)
I'm working on some javascript legacy code and I came across this conditional, can anyone tell me what does the '?' do? The 'items' property is not part of the currentItem object and it never is...
if (currentItem?.items)
See: Optional Chaining in JavaScript
That's the optional chaining operator.
The optional chaining operator (?.) permits reading the value of a property located deep within a chain of connected objects without having to expressly validate that each reference in the chain is valid.
Read more: Optional chaining (?.) (MDN)