You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you try to access a property on the new object, it checks the object’s own properties first. If it doesn’t find it there, it checks the [[Prototype]], and so on up the prototype chain until it gets back to Object.prototype, which is the root delegate for most objects.
class
class Greeter {constructor (name) {this.name = name || 'John Doe';}hello () {return Hello, my name is ${ this.name };}}
const george = new Greeter('George');
const msg = george.hello();
console.log(msg); // Hello, my name is George
Factory
const proto = {hello () {return Hello, my name is ${ this.name };}};