JingchaoZhao / js-learning

knowledge of webs
0 stars 0 forks source link

tips: Object.prototype.toString.call() instanceof isArray #7

Open JingchaoZhao opened 5 years ago

JingchaoZhao commented 5 years ago
image
JingchaoZhao commented 5 years ago

instanceof 的内部机制是通过判断对象的原型链中是不是能找到类型的prototype。

只能用来判断对象类型,原始类型不可以。

JingchaoZhao commented 5 years ago

isArray es5后才有,更低用toString来实现