How to check if a javascript variable is defined

Author: , October 21st, 2009

[code]if ( typeof(myVar) !== ‘undefined’) { // variable is defined } [/code] ~or~ [code]if (typeof variable === ‘undefined’ || variable === null) { // variable is undefined or null } [/code]