MDN对object instanceof constructor的说明,instanceof 用来判断constructor.prototype是否存在于object原型链中。
下面给个例子
var str = new String()
var str2 = "456"
console.log(typeof str)//object
console.log(typeof str2)//string
//object instanceof constructor
//instanceof 运算符用来检测 constructor.prototype 是否存在于参数 object 的原型链上。
console.log( str instanceof String )//true
console.log( str2 instanceof String )//false
console.log(str.__proto__)
console.log( String.prototype )
console.log( String.prototype.__proto__ )
console.log( Object.prototype.__proto__)
console.log( String.prototype )输出
对于str它的原型链是这样的