📌The Constructor Method
💎The constructor method is a special method:
👉It has to have the exact name "constructor"
👉It is executed automatically when a new object is created
👉 It is used to initialize object properties
🔑If you do not define a constructor method, JavaScript will add an empty constructor method.
@javascript_tut
"w3schools .com"
💎The constructor method is a special method:
👉It has to have the exact name "constructor"
👉It is executed automatically when a new object is created
👉 It is used to initialize object properties
🔑If you do not define a constructor method, JavaScript will add an empty constructor method.
@javascript_tut
"w3schools .com"
📌Class Methods
💎Class methods are created with the same syntax as object methods.
💎Use the keyword class to create a class.
💎Always add a constructor() method.
💎Then add any number of methods.
@javascript_tut
"w3schools .com"
💎Class methods are created with the same syntax as object methods.
💎Use the keyword class to create a class.
💎Always add a constructor() method.
💎Then add any number of methods.
@javascript_tut
"w3schools .com"
📌Class extends
💎The extends keyword is used to create a child class of another class (parent).
💎The child class inherits all the methods from another class.
🔑Inheritance is useful for code reusability: reuse properties and methods of an existing class when you create a new class.
📎Note: From the example above; The super() method refers to the parent class. By calling the super() method in the constructor method, we call the parent's constructor method and gets access to the parent's properties and methods.
@javascript_tut
"w3schools .com"
💎The extends keyword is used to create a child class of another class (parent).
💎The child class inherits all the methods from another class.
🔑Inheritance is useful for code reusability: reuse properties and methods of an existing class when you create a new class.
📎Note: From the example above; The super() method refers to the parent class. By calling the super() method in the constructor method, we call the parent's constructor method and gets access to the parent's properties and methods.
@javascript_tut
"w3schools .com"
📌Static Keyword
💎The static keyword defines static methods for classes.
💎Static methods are called directly on the class (Car from the example above) - without creating an instance/object (mycar) of the class.
@javascript_tut
"w3schools .com"
💎The static keyword defines static methods for classes.
💎Static methods are called directly on the class (Car from the example above) - without creating an instance/object (mycar) of the class.
@javascript_tut
"w3schools .com"
Mongodb, Expressjs, Reactjs and Nodejs
MEAN is a free and open-source JavaScript software stack for building dynamic web sites and web applications.
https://t.me/mern_stack_tut
MEAN is a free and open-source JavaScript software stack for building dynamic web sites and web applications.
https://t.me/mern_stack_tut
Telegram
MERN Stack ✅
Mongodb, Expressjs, Reactjs and Nodejs
MEAN is a free and open-source JavaScript software stack for building dynamic web sites and web applications.
MEAN is a free and open-source JavaScript software stack for building dynamic web sites and web applications.