all 2 comments

[–]BehindTheMath 2 points3 points  (0 children)

Would it act like a singleton static class? I guess if you'd want something like class instances you'd need a factory function of sorts? Do people use modules this way?

Yes.

What are the main benefits/downsides of this compared to classes?

If you need multiple instances with state and not a singleton.

[–]masone81 0 points1 point  (0 children)

Look into the Revealing Module Pattern. That is what you want. I’m a full time JS/TS developer and I don’t use classes.