How to check if a javascript variable is defined

Published Date Author: , 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]

No comments as yet.

Leave Your Comment  Leave a comment

All fields marked with "*" are required.