Posted By

tonic on 01/19/09


Tagged

check test variable exists var determine


Versions (?)

Test if variable exists


 / Published in: JavaScript
 

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

  1. var foo = "bar";
  2.  
  3. if ( typeof( window[ 'foo' ] ) != "undefined" ) {
  4. document.write("foo is defined")
  5. } else {
  6. document.write("foo is undefined")
  7. }

Report this snippet  

You need to login to post a comment.