๐๐ฎ๐ ๐ฎ๐ฒ ๐ผ๐ณ ๐๐ฒ๐ฎ๐ฟ๐ป๐ถ๐ป๐ด ๐ ๐๐ฅ๐ก ๐ฆ๐๐ฎ๐ฐ๐ธ
I am on day 26 of my MERN stack journey. Today I moved from prototype manipulation to ES6 Classes and Inheritance.
Yesterday I learned how single objects share methods. Today I learned how to build blueprints for objects. This makes your code scalable.
I studied Object-Oriented Programming (OOP) in JavaScript. Here are the main points:
โข A class acts as a blueprint for your objects. โข The constructor() method runs automatically when you create a new object. โข Use the new keyword to create an instance of a class. โข The constructor is the best place to set initial properties.
Example:
class Car { constructor(brand, hp) { this.brandName = brand; this.horsepower = hp; } }
let myCar = new Car("Toyota", 180);
This method allows you to build many objects quickly using one template.
Source: https://dev.to/ali_hamza_589ec7b3eb6688d/dau-26-of-learning-mern-stack-2j4e