Test if a variable existsTag(s): Language


var foo = "bar";

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

And for fubar :


blog comments powered by Disqus