欢迎您访问新疆栾骏商贸有限公司,公司主营电子五金轴承产品批发业务!
全国咨询热线: 400-8878-609

新闻资讯

常见问题

JavaScript判断undefined类型的正确方法

作者:用户投稿2026-01-11 20:57:09

复制代码 代码如下:
  if (reValue== undefined){
    alert("undefined");
    }

发现判断不出来,最后查了下资料要用typeof
方法:
复制代码 代码如下:
if (typeof(reValue) == "undefined") {
   alert("undefined");


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