Javascript — Object-Oriented Programming
JavaScript supports OOP using prototypes and ES6 classes. Classes enable defining blueprints for objects, including properties and methods. Key concepts include inheritance, encapsulation, and polymorphism, allowing complex and reusable code structures.
class Animal {
constructor(name) { this.name = name; }
speak() { console.log(`${this.name} makes a noise.`); }
}
class Dog extends Animal {
speak() { console.log(`${this.name} barks.`); }
}
const dog = new Dog('Rex');
dog.speak();