JavaScript null check
I've come across the following code: function test(data) { if (data != null && data !== undefined) { // some code here } } I'm somewhat new to JavaScript, but, from other questions I've been reading here, I'm under the impression that this code does not make much sense. In particular, this answer states that You'll get an error if you access an undefined variable in any context other than typeof . Update: The (quote of the) answer above may be misleading. It should say «an undeclared variable» , instead of «an undefined variable» . As I found out, in the answers by Ryan ♦ , maerics , and