showing results for - "prototype chain in javascript"
Lana
22 Oct 2017
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
Agustina
16 Sep 2017
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}
queries leading to this page
prototype chaining jsjavascript prototype chain in javascriptprototype of function in javascriptunderstanding the javascript prototype chain 26 inheritance 7c 40risingstackhow to see prototype chain in javascriptjavascript prototype chainprototype chain vs internal 5b 5bprototype 5d 5djs print prototype chainwhat is function prototype in javascriptwhat is the prototype chain javascriptprototype chain prototype and prototype chaining in javascriptjavascript prototype chain examplethe prototype chain javascriptprototype in jsjavascript ptotochaining js examplesprototype methods javascript includewhat is prototype chain in javascript 3funderstanding javascript prototype chainprototype chainprototype chaining in javascriptprototype javascript esempiojs whole prototype chainprototype chain in javascriptdo we still use the prototype chain in javascriptcreating prototype chain jswhat is a prototype chain in javascript examplejs prototype chainhow prototype chain in javascript worksprototype chain in javascript mediumprototype chain in jsexplaining javascript e2 80 99s prototype chain like you 27re fivewhat is prototype chaining in javascriptwhat is the js protype chainjavascript prototype inheritanceaccess to prototype chain jspractice prototype methods javascript prototype chaining in jaavscriptprototype chain and keyword newprototype chaining in javascript examplefor in prototype chainwhat is js prototype chainprototype chaining in javascript memesbehaviour of prototype chain in javascriptcreating prototype chain in constructor function jsprototype chain exampleunderstand the prototype chainprototype objects in chainwhat is a prototype chain for method sharingprototype chaining of functions in javascriptwhat is a prototype chain in javascriptwhat is prototype chain in javascriptprototype chaining javascriptis it still necessary to use the prototype chain manually javascriptprototypal inheritancehow method chaining works in javascirptobject prototype chainattach function in prototype chain jsobject property inharit javascriptjavascript the prototype chainprototype chain for ahow to create prototype chainwhat is prototype chainingprototype chaining inheritanceprototype chain in esprototype chain javascriptprototype chainingprototype chain jsmethod and prototype chain in javascripthow to create prototype chain jsjs get prototype chainprototype chain in javascript