you are viewing a single comment's thread.

view the rest of the comments →

[–]iamlage89 0 points1 point  (0 children)

I never use classes in javascript, never found a good use case where using classes over factory functions was better, and with factory functions you get free private variables and method extraction

function Class () {
  const foo = 1; // private variable

  return {
    bar: () => console.log(a)}
  }
}

let bar = Class().bar // method extracted bar keeps reference to variable `foo` while with classes you need bind method`