Javascript判断变量等是否为空undefined

admin 发布时间:2014-11-21 分类:Web 阅读:4024次 3 条评论

要判断的变量Value,判断Value是否为undefined:

if (typeof(Value) == "undefined") { 

   alert("undefined"); 

}

else

{

    alert(Value); 

}

typeof 后返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined"....

新手勿喷....


已有3条留言
  • 雨夜
    发布于 2014-12-04 22:36:24  回复该评论
  • 我也是来学习的。嘿嘿。我是新手的新手啊。。
  • 极品飞鸽
    发布于 2014-11-25 20:35:00  回复该评论
  • 俺知道这个typeof,O(∩_∩)O哈哈~
    但是很少用。 而且IE和chrome好像不同 特别是function
  • 香港服务器租
    发布于 2014-11-24 17:20:46  回复该评论
  • 你好!我这里有个独立ip主机3.8折的广告图推荐给你如何?如果可以的话,请加我qq:2954243953

发表评论:

◎欢迎您的参与讨论。