In which specific cases does property access throw an error in JavaScript?
In Node.js, this prints undefined
:
x = 3
console.log( x.thing );
This throws an error:
x = null;
console.log( x.thing );
What exactly is the semantics here? Property access is normal behavior for almost all values—even functions—but on undefined
and null
it throws an error.
I can't for the life of me find confirmation that those are the only cases. Can anybody confirm that?