, String instanceof Object, String - , - JavaScript.
prototype , . , , new . ( , .) String Function.prototype ( String - ), ES5 getPrototypeOf:
Object.getPrototypeOf(String) === Function.prototype
ES6 __proto__ ( ), , ):
String.__proto__ === Function.prototype // true
, , String - ; Object? , :
String.__proto__.__proto__ === Object.prototype
Object.getPrototypeOf(Object.getPrototypeOf(String)) === Object.prototype
, .prototype.prototype .__proto__.__proto__:
snippet.log(String.__proto__ === Function.prototype);
snippet.log(String.__proto__.__proto__ === Object.prototype);
<script src="http://tjcrowder.imtqy.com/simple-snippets-console/snippet.js"></script>
:
function GrandParent() {
}
function Parent() {
GrandParent.call(this);
}
Parent.prototype = Object.create(GrandParent.prototype);
Parent.prototype.constructor = Parent;
function Child() {
Parent.call(this);
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
var c = new Child();
snippet.log(c.__proto__ === Child.prototype);
snippet.log(c.__proto__.__proto__ === Parent.prototype);
snippet.log(c.__proto__.__proto__.__proto__ === GrandParent.prototype);
<script src="http://tjcrowder.imtqy.com/simple-snippets-console/snippet.js"></script>