在许多第三方库和最佳实践博客/推荐等中……看到这样的语法是很常见的:
typeof x === 'object' (instead of typeof x == 'object')
typeof y === 'string' (instead of typeof x == 'string')
typeof z === 'function' (instead of typeof x == 'function')
如果 typeof 运算符已经返回一个字符串,那么还需要对返回值进行类型检查吗?如果 typeof(typeof(x)) 总是string,不管 x 实际上是什么,那么==就足够了,而===不必要。
在什么情况下 typeof不会返回字符串文字?即使有一些边缘情况,为什么额外的类型检查被用于对象、字符串、函数等......