js判断undefined类型

看到同事写的前端代码判断undefind:

 发现判断不出来,最后查了下资料要用typeof
方法:
if (typeof(reValue) == "undefined") {
   alert("undefined");
}  
typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined"

https://www.jb51.net/article/48512.htm

实践出真知。下面的代码又会怎样呢

       var o = {};
    
    //if(typeof(abc) == "undefined")  // ok
    //if( abc == undefined ) // error
    if( o.abc == undefined )  // ok
    {
        alert('abc undefined'); return;
    }
原文地址:https://www.cnblogs.com/zhangmo/p/15702182.html