[thelist] What's the most reliable way to check a javascript null?

Jonathan Dillon jdillon at boehm-ritter.com
Thu Feb 17 13:56:15 CST 2005

Howdy all:

I'm wondering if, in javascript:

if (Variable != "null")
if (Variable != null)
if (Variable != "")
if (Variable != '')
if (variable)
... are equivalent... And whether one is "best practice" or whether one
needs several of these tests to accommodate all browsers.

I'm writing a test case to determine whether a javascript variable exists.

Any thoughts?


More information about the thelist mailing list