instanceof
が優先されます。__proto__
は非標準です。具体的には、Internet Explorer では機能しません。
Object.getPrototypeOf(obj)
と同じことを行う ECMAScript 5 関数です__proto__
。
instanceof
プロトタイプ チェーン全体を検索するのに対し、getPrototypeOf
1 つ上のステップのみを検索することに注意してください。
いくつかの使用上の注意:
new String() instanceof String // true
(new String()).__proto__ == String // false!
// the prototype of String is (new String(""))
Object.getPrototypeOf(new String()) == String // FALSE, same as above
(new String()).__proto__ == String.prototype // true! (if supported)
Object.getPrototypeOf(new String()) == String.prototype // true! (if supported)