Pavle
Marinkovic
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;
})();
π₯
export class MyClass {
constructor() {
if (MyClass._instance) {
return MyClass._instance;
}
MyClass._instance = this;
}
}
π₯
Medior π€΅ββοΈ
class Singleton {
// Class implementation
}
export const SingletonInstance = new Singleton();
π₯
Senior π§ββοΈ
Junior πΆ
Singleton Pattern
Junior πΆ vs Medior π€΅ββοΈ vs Senior π§ββοΈ
Swipe