DEV Community

Discussion on: You don't need null

 
martinpham profile image
Martin Pham

I’m not talking about the check. I’m just trying to point the inconsistency between two cases about the same thing.

 
loucyx profile image
Lou Cyx

But that's the thing, they aren't the same thing. One is trying to access something not declared in the scope, while the other is trying to access a property of something that is declared in the scope. You can test both with typeof === "undefined", but if you try to access something undeclared you get an error, which sucks, but that's how it works. Nowadays is very difficult to end up in this scenario tho, because editors will let you know if you're trying to access an undeclared value.

Some comments have been hidden by the post's author - find out more