Inheritance

noun

say it: “in-HAIR-ih-tunss” /ɪnˈhɛrɪtəns/

A way for one class to start with everything another class has, then add to it or change parts of it.

What is Inheritance in JavaScript?

Inheritance — A new class starts with everything from another class, then adds or changes things.

class Alert {
    text() {
        return "Alert";
    }
}

class EmailAlert extends Alert {
    text() {
        return "Email";
    }
}

In a sentence

  • “Through inheritance, Fighter gets Ship's shields and fly method without copying them.”

Level: Journeyman · More JavaScript terms at this level

Updated

In other subjects