on-internet
← Community

Javascript `?.` operator: why is `not defined` not treated as `undefined`?

Stack Overflow ·

Assuming w has not been previously defined, the following JS code gives ReferenceError: w is not defined: w?.y; whereas this code simply returns undefined: let w; w?.y; Why does the ?. operator not treat not defined as undefined?

Comments

Sign in or sign up to comment and upvote.

No comments yet.