Return to Snippet

Revision: 10954
at January 19, 2009 08:39 by tonic


Initial Code
var foo = "bar";

if ( typeof( window[ 'foo' ] ) != "undefined" ) {
   document.write("foo is defined")
} else {
   document.write("foo is undefined")
}

Initial URL
http://www.rgagnon.com/jsdetails/js-0112.html

Initial Description


Initial Title
Test if variable exists

Initial Tags


Initial Language
JavaScript