Prototypes in JavaScript
Understand JavaScript prototypes
AdvancedAdvanced JSExample 1 of 12
prototypes.js
1function Person(name) { this.name = name; }2Person.prototype.greet = function() { return 'Hello, ' + this.name; };3const person = new Person('John');4console.log(person.greet());
Output
Hello, John
What's going on
Prototypes enable object inheritance.