OOP (Object-Oriented Programming)Classes and Objects

Classes are the core building blocks of OOP. A class is like a blueprint or template for creating objects. It defines what properties (variables) and methods (functions) an object will have. Objects are actual instances created from these classes. For example, if you have a class called 'Dog', you can create multiple dog objects with different names and breeds. Classes make it easy to organize related code together and reuse it whenever needed. You can think of a class as a cookie cutter and objects as the cookies made from it.

class Dog {
  constructor(name, breed) {
    this.name = name;
    this.breed = breed;
  }
  bark() {
    console.log(this.name + ' says Woof!');
  }
}
let dog1 = new Dog('Buddy', 'Labrador');
dog1.bark();