Object.prototype
. But any object can be used
as a prototype.Object.prototype
.
The image below shows the prototype chain for the code in this example:
function Test(val) { this.a = val; }
Test.prototype.b = 42;
var one = new Test(1), two = new Test(2);
one
{ "a": 1, "b": 42 }
two.b = 7337;
two
{ "a": 2, "b": 7337 }
one
{ "a": 1, "b": 42 }
Test.prototype.c = 'test';
one
{ "a": 1, "b": 42, "c": "test" }
Object.getPrototypeOf(one)
{ "b": 42, "c": "test" }
one.hasOwnProperty('b')
false
The console allows you to interact with the course material and examples. Use the following keys:
A special logging function is also available:
prototype
property contains an empty object that is used when instances are created withnew
.