- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Class Inheritance
JavaScript Classes
JavaScript Class Inheritance
extendscreates a class that inherits everything from another class.
The new class gets all the methods of the one it extends.
It can add its own, and replace any it does not want.
Example
Example
javascript
class Animal {
speak() {
return "some sound";
}
}
class Dog extends Animal {}
console.log(new Dog().speak());