How to check if a javascript variable is defined
erics, Posted October 21st, 2009 at 7:35:15pm
[code]if ( typeof(myVar) !== ‘undefined’) {
// variable is defined
}
[/code]
~or~
[code]if (typeof variable === ‘undefined’ || variable === null) {
// variable is undefined or null
}
[/code]
Leave Your Comment
All fields marked with "*" are required.