Possible Duplicate:
Detecting an undefined object property in JavaScript
Would it be like this?
if(variable == undefined) {
or would it be like this?
if(variable == "undefined") {
Possible Duplicate:
Detecting an undefined object property in JavaScript
Would it be like this?
if(variable == undefined) {
or would it be like this?
if(variable == "undefined") {
if(typeof(variable) == 'undefined')
typeof is an operator and not a function.Use the typeof operator here, like this:
if(typeof variable == "undefined") {
typeof when simply checking variable == undefined works?undefined may be redefined, for example: jsfiddle.net/nick_craver/gHjg5