var exp=undefinded; if(typeof(exp)=="undefined") { //变量是undefined的处理 }
typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined",
下图是控制台测试例子:
JavaScript/jQuery判断变量是否是undefined
原文:https://www.cnblogs.com/HapetyPing/p/13305106.html