if("undefined"===typeof myVar){ alert("未定义"); }
不用:
var myVar; if(undefined===myVar){ alert("未定义"); }