Page 1 of 1

javascript

PostPosted: Wed Sep 15, 2010 2:39 am
by swamarpika
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

Re: javascript

PostPosted: Thu Sep 16, 2010 1:53 am
by cantlep
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..

Re: javascript

PostPosted: Fri Sep 17, 2010 11:22 am
by shannah
In javascript you can use the typeof() function on your variable.
e.g.
Code: Select all
if ( typeof(myvar) == 'undefined' )  // then it is undefined