Pavle

Marinkovic

for-loop.js
export var Foo = (function () {
  "use strict";
  var instance;
  function Singleton() {
    if (instance) return instance;
    instance = this;
  }
  Singleton.getInstance = function () {
    return instance || new Singleton();
  };
  return Singleton;
})();

πŸ₯‰

fill-map.js
export class MyClass {
  constructor() {
    if (MyClass._instance) {
      return MyClass._instance;
    }
    MyClass._instance = this;
  }
}

πŸ₯ˆ

Medior πŸ€΅β€β™‚οΈ

keys.js
class Singleton {
  // Class implementation
}

export const SingletonInstance = new Singleton();

πŸ₯‡

Senior πŸ§™β€β™‚οΈ

Junior πŸ‘Ά

JavaScript logo

Singleton Pattern

Junior πŸ‘Ά vs Medior πŸ€΅β€β™‚οΈ vs Senior πŸ§™β€β™‚οΈ

Swipe