1:操作数数量不同
typeof的操作数是 1个
instanceof的操作数是 2个
# 1个操作数
console.log(typeof('strings'));
# 2个操作数
var c = new String('Hellos');
console.log(c instanceof String);
https://link.juejin.cn?target= 2:返回值不同
typeof返回的是字符串 数据类型
instanceof返回的是布尔值
https://link.juejin.cn?target= 3:操作数类型不同
typeof操作的可以是简单数据类型,函数,或者对象
instanceof操作的 左边必须是引用类型 右边必须是函数
具体代码:见区别1
https://link.juejin.cn?target= 4:typeof能识别引用类型但是不能再细分
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5CMxQzY1UzN0ADMzEmYmBTOjZDN0kDMmNWZ3MGZlFTY18CX5d2bs92Yl1iclB3bsVmdlR2LcNWaw9CXt92Yu4GZjlGbh5yYjV3Lc9CX6MHc0RHaiojIsJye.png)
5:instanceof 的简单理解
判断A是否是B的实例
A instanceof B