DEV Community

loading...

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

Collapse
leviathanprogramming profile image
𝐋𝐄𝑽𝐈𝑨𝐓𝐇𝐀𝐍 Programming

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.