DEV Community

Discussion on: I Don't Use JavaScript Classes At All. Am I Missing Out on Something?

Collapse
 
ironcladdev profile image
IroncladDev

I don't really use JS classes either. I use OOP by making a constructor with a function.

function Unit(stats){
  this.stats = stats;
};
Unit.prototype.run = function(){
  //...
};
Enter fullscreen mode Exit fullscreen mode
Collapse
 
shadowtime2000 profile image
shadowtime2000

This is probably worse because it adds an unnecessary amount of code and is harder to understand at the start, especially with large classes.