【发布时间】:2016-01-03 12:34:56
【问题描述】:
function a(){ return true; }
var b = function(){ return true; };
window.c = function(){ return true; };
console.log(typeof a);//returns funtion
console.log(typeof b); //returns funtion
console.log(typeof window.c); //returns funtion
typeof a === typeof b === typeof window.c //returns false
在控制台中运行上述代码时,最后的语句为 false。而所有 3 个函数的 typeof 都返回函数。我知道 javascript 中有一些带有 typeof 的奇怪部分..你们能解释一下吗..
【问题讨论】:
-
答案:
true === typeof window.c是false。 -
typeof a === typeof b被评估为true。
标签: javascript equality typeof