re: What was the most difficult thing to learn about JavaScript for you? VIEW POST

re: You don't actually need to use classes in JavaScript. Some frameworks might encourage you towards them but still... it's an option. I understand th...

I went through a couple of years loving classes until I realized that I didn't really use them to base or extend anything and I was in fact not doing OOP, classes are synonymous with Oop but really it's just a data structure. You could even do functional with Classes. Ultimately the humble Object literal is pretty much offering the same thing.

const ClassLike = {
   new() {
     return Object.create(this, {})
   publicProp: 2

const inst = ClassLike.new();

So with that I could even do async construtors, multi inheritance and much more (for better or worse).
The one or two things I would miss, class is the only syntax where decorators are supported and I suppose the new class features like real privacy class field syntax do make classes 80% more appealing again.

I have been working on this thing and it has to be a class to write it this way.

class SimpleRouter {
   @get ['/home']
   ({ res }) {
      return res.html();

   @post ['submit/myform']
   ({ somePlugin, res }) {
code of conduct - report abuse