我正在尝试检查变量是否是这样的对象:
if(obj && typeof obj === Object) {
console.log('obj is an object and does not return null value');
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
typeof返回类型的字符串表示形式,但是如果要检查null则
if(typeof obj === 'object' && obj !== null) {
console.log('obj is an object and does not return null value');
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
79 次 |
| 最近记录: |