【发布时间】:2015-04-22 08:10:02
【问题描述】:
我的 JavaScript 说 instanceof 运算符搜索原型属性是否存在于构造函数中。
String instanceof Object; // true
String.prototype === Object.prototype; // false
String.prototype.prototype === Object.prototype; // false
String.prototype.prototype.prototype === Object.prototype; // Throws into "Cannot read property 'prototype' of undefined"
String.prototype.prototype; // undefined
这仅仅意味着 Object.prototype 不存在于 String.prototype 链上。
这让我很困惑,那么String instanceof Object 怎么会返回 true?
【问题讨论】:
标签: javascript prototype instanceof