prototype chain in javascript
var o = {
a: 2,
m: function() {
return this.a + 1;
}
};
console.log(o.m()); // 3
// When calling o.m in this case, 'this' refers to o
var p = Object.create(o);
// p is an object that inherits from o
p.a = 4; // creates a property 'a' on p
console.log(p.m()); // 5
// when p.m is called, 'this' refers to p.
// So when p inherits the function m of o,
// 'this.a' means p.a, the property 'a' of p
{
prop: "some value",
__proto__: {
foo: "bar",
constructor: ƒ doSomething(),
__proto__: {
constructor: ƒ Object(),
hasOwnProperty: ƒ hasOwnProperty(),
isPrototypeOf: ƒ isPrototypeOf(),
propertyIsEnumerable: ƒ propertyIsEnumerable(),
toLocaleString: ƒ toLocaleString(),
toString: ƒ toString(),
valueOf: ƒ valueOf()
}
}
}
Also in JavaScript:
- como diminuir quantidade de casas decimais javascript
- javascript get object from array where property equals
- eliminare spazi inizio e fine stringa javascript
- javascript sort chars in string
- drag n drop file upload react
- Switch Button in react
- convertir seconde
- span change jquery
- error vuejs from chokidar enospc
- Removing duplicates in an Array of Objects
- js class async constructor
- disabled radio button
- javascript backticks and if statements
- avoid compressing imagepicker react native
- update to node 12 mac
- select option value jquery
- javascript dictionary
- javascript convert binary to text
- fs.writefile
- js indexof string
- jquery validate on keyup
- reduce method javascript
- react big calendar event color
- go to another page javascript