constSingleton=(function(){letinstance=null;returnfunctionSingleton(){if (!new.target){thrownewError("`Singleton()` must be called with `new`");}if (instance!==null){returninstance;}instance=this;// Init properties and set methods...};})();
A skilled software engineer, talented problem-solver and team player with a passion for using technology to solve complex problems and constantly seeking out new challenges to advance my skills👨🏼💻
I would do it this way:
Allowing you to use
new
:Of course it can be done without ES6 classes too:
Yeah, that can be a way of implementing it.