javascript

Archived from the Xataface Users forum.

swamarpika — Wed Sep 15, 2010 2:39 am

How would you check to see if a JavaScript variable is defined? I wrote a JavaScript program that works for the most part. Unfortunately, one of the features of the program is not responding correctly. I’m thinking that one of the variables is not defined and was wondering if anyone knew of any methods to check to see if this is the case.
___________________________
yahoo keyword tool ~ overture ~ traffic estimator ~ adwords traffic estimator


cantlep — Thu Sep 16, 2010 1:53 am

Last time I needed to check something similar with JSON and JS, I just viewed the source of the page and I could see what was created and what wasn’t….You may have already tried this…but it helped me out..


shannah — Fri Sep 17, 2010 11:22 am

In javascript you can use the typeof() function on your variable.
e.g.

Code: Select all
if ( typeof(myvar) == 'undefined' )  // then it is undefined