如何检查JavaScript变量是否未定义?[重复]

2020/10/19 19:42 · javascript ·  · 0评论

我尝试过的事情似乎不起作用:

if(lastName != "undefined")
if(lastName != undefined)
if(undefined != lastName)

var lastname = "Hi";

if(typeof lastname !== "undefined")
{
  alert("Hi. Variable is defined.");
} 
本文地址:http://javascript.askforanswer.com/ruhejianchajavascriptbianliangshifouweidingyizhongfu.html
文章标签: ,  
版权声明:本文为原创文章,版权归 javascript 所有,欢迎分享本文,转载请保留出处!

文件下载

老薛主机终身7折优惠码boke112

上一篇:
下一篇:

评论已关闭!