๐๐ฎ๐ ๐ฎ๐ฒ ๐ผ๐ณ ๐๐ฒ๐ฎ๐ฟ๐ป๐ถ๐ป๐ด ๐ ๐๐ฅ๐ก ๐ฆ๐๐ฎ๐ฐ๐ธ
I am on day 26 of my MERN stack journey.
Today I moved from prototype manipulation to ES6 Classes and Inheritance. I watched lecture 9 from the Apna College JavaScript series.
Yesterday I learned how single objects share methods. Today I learned how to build blueprints for objects. This helps you build scalable code.
I studied Object-Oriented Programming (OOP) in JavaScript.
Here are the main points:
- A class acts as a blueprint for objects.
- The constructor() method lives inside every class.
- The constructor runs automatically when you use the new keyword.
- You use the constructor to set initial properties for your objects.
Example:
class Car { constructor(brand, hp) { this.brandName = brand; this.horsepower = hp; } }
let myCar = new Car("Toyota", 180);
This code creates a fresh object instantly.
Source: https://dev.to/ali_hamza_589ec7b3eb6688d/dau-26-of-learning-mern-stack-2j4e