how to create prototype chain js code example
Example 1: prototype chain in javascript
var o = {
a: 2,
m: function() {
return this.a + 1;
}
};
console.log(o.m());
var p = Object.create(o);
p.a = 4;
console.log(p.m());
Example 2: prototype chain in javascript
{
prop: "some value",
__proto__: {
foo: "bar",
constructor: ƒ doSomething(),
__proto__: {
constructor: ƒ Object(),
hasOwnProperty: ƒ hasOwnProperty(),
isPrototypeOf: ƒ isPrototypeOf(),
propertyIsEnumerable: ƒ propertyIsEnumerable(),
toLocaleString: ƒ toLocaleString(),
toString: ƒ toString(),
valueOf: ƒ valueOf()
}
}
}