Yes, there are many ways to create and use objects. So why / when is it better to create a constructor compared to a class declaration and use the constructor () method? My instructor said that it does not matter, but I do not believe him.
function Grumpy(name, profile, power){
this.name = name;
this.profile = profile;
this.power = power;
}
Against
class Grumpy{
constructor(name, profile, power){
this.name = name;
this.profile = profile;
this.power = power;
}
}
source
share