Back to Lessons

JavaScript Prototypes and Inheritance

April 5, 2026

Prototype Inheritance

JavaScript's object-oriented inheritance mechanism.

Prototype Example

function Person(name) {
    this.name = name;
}

Person.prototype.greet = function() {
    return "Hi, I'm " + this.name;
};

function Student(name, grade) {
    Person.call(this, name);
    this.grade = grade;
}
Student.prototype = Object.create(Person.prototype);

let student = new Student("John", "A");
console.log(student.greet()); // "Hi, I'm John"

Key Points

  • __proto__, prototype chain.
  • Object.create() for prototypal inheritance.
  • Class syntax (ES6) syntactic sugar over prototypes.
  • instanceof checks prototype chain.