Student.prototype = Object.create(Person.prototype); Student.prototype.constructor = Student;. In the constructor: Person.call(this, name). This sets up the prototype chain manually.
How do you implement inheritance with constructor functions in JavaScript?
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().
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.
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.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.