Are ES6 classes different from the prototype system?
No. ES6 classes are syntactic sugar over the prototype system. class Person { greet() {} } puts greet on Person.prototype. extends sets up the prototype chain. It is the same mechanism with cleaner syntax.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Prototype Interview Questions in JavaScript
__proto__ is on every object and points to its actual prototype. prototype is on functions and is the object that instances created with new will inherit from. obj.__proto__ === Constructor.prototype for objects created with new Constructor().
Student.prototype = Object.create(Person.prototype); Student.prototype.constructor = Student;. In the constructor: Person.call(this, name). This sets up the prototype chain manually.
Creates an object with no prototype (no __proto__). It has no inherited properties (no toString, no hasOwnProperty). Useful for hash maps or dictionaries where you do not want any inherited properties.
Still have questions?
Browse all our FAQs or reach out to our support team
