⊗jsOpBsCP 11 of 60 menu

Parameters in a Constructor in OOP in JavaScript

You can pass parameters to the constructor. Let's look at an example:

class User { constructor(name, surn) { console.log(name + ' ' + surn); } }

Let's pass the parameters at the time of object creation:

new User('john', 'smit');

Pass the employee's name and salary to the Employee class constructor.

hudesvuzluzc