1var o = {
2 a: 2,
3 m: function() {
4 return this.a + 1;
5 }
6};
7
8console.log(o.m()); // 3
9// When calling o.m in this case, 'this' refers to o
10
11var p = Object.create(o);
12// p is an object that inherits from o
13
14p.a = 4; // creates a property 'a' on p
15console.log(p.m()); // 5
16// when p.m is called, 'this' refers to p.
17// So when p inherits the function m of o,
18// 'this.a' means p.a, the property 'a' of p
19
20
21
1{
2 prop: "some value",
3 __proto__: {
4 foo: "bar",
5 constructor: ƒ doSomething(),
6 __proto__: {
7 constructor: ƒ Object(),
8 hasOwnProperty: ƒ hasOwnProperty(),
9 isPrototypeOf: ƒ isPrototypeOf(),
10 propertyIsEnumerable: ƒ propertyIsEnumerable(),
11 toLocaleString: ƒ toLocaleString(),
12 toString: ƒ toString(),
13 valueOf: ƒ valueOf()
14 }
15 }
16}