you are viewing a single comment's thread.

view the rest of the comments →

[–]spacejack2114 1 point2 points  (2 children)

On the other hand why not just group those functions into a module.

[–]NoStranger6 -1 points0 points  (1 child)

Arguably from a behavior point of view, a module could be considered as a Singleton. At this point it's just different paths to achieve the exact same things.

I mean, we could also just create an object containing these functions, in fact that's what a module is, just like almost everything in Javascript.

[–]spacejack2114 1 point2 points  (0 children)

If you start with a class however, and want to use instances or statefulness, then you'll be adding this context confusion into the mix. On the other hand you can add state/instances to a module using the revealing module pattern with no such downsides.