Post your trick

condition to determine if a javascript variable has been defined or not

In php to determine if a certain variable is set we use the function,


isset($variable)



it returns a boolean value.
To do the same thing in javascript, use the following condition,


if(typeof variable != ‘undefined’){
alert(’This variable is not defined yet’);
}
else {
alert(’The variable is defined’);
}


Leave a Reply

     

     

     

Post A Trick !

How does "Kodetricks" work?

We at kodeplay like to share knowledge. With Kodetricks, even you can join us. All you need to do is post a programming related trick if you have one or rate a trick if you like someone else's.



Technology

Contact Us