在许多第三方库和最佳实践博客/推荐等中......通常会看到如下语法:
typeof x === 'object' (instead of typeof x == 'object')
typeof y === 'string' (instead of typeof x == 'string')
typeof z === 'function' (instead of typeof x == 'function')
Run Code Online (Sandbox Code Playgroud)
如果typeof运算符已经返回一个字符串,那么还需要键入什么来检查返回值?如果typeof(typeof(x))总是字符串,无论x实际上是什么,那么==应该足够了并且===不必要.
在什么情况下typeof 不会返回字符串文字?即使有一些边缘情况,为什么附加类型检查用于对象,字符串,函数等...