实际上是否可以将Null数据类型作为typeof函数的返回值 - 如果是这样的话会产生哪种结果,何时实际上是该Null类型的变量 ?
typeof myVAR; //gives me "undefined" before the variable declaration
var myVAR;
typeof myVAR; //also gives me "undefined"
myVAR = null; //assigned the null object
typeof myVAR; //gives me "Object" (which I guess makes sense because `null` is an object and that's what I assigned to the variable)
Run Code Online (Sandbox Code Playgroud)
typeof永远不会返回"null",但有一个内部null类型:
测试null的唯一方法是null使用===运算符直接与值进行比较.