We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f9aae2 commit ed4bbffCopy full SHA for ed4bbff
Roadmap/23 - SINGLETON/javascript/bernatcs.js
@@ -0,0 +1,15 @@
1
+// ** EJERCICIO
2
+
3
+class Singleton {
4
+ constructor() {
5
+ if (Singleton.instance) {
6
+ return Singleton.instance;
7
+ }
8
+ this.data = "Información del Singleton"; // Propiedades de la instancia
9
+ Singleton.instance = this; // Guardar la instancia
10
+ Object.freeze(this); // Congelar la instancia para evitar modificaciones
11
12
+}
13
14
+const instance = new Singleton();
15
+const instance2 = new Singleton()
0 commit comments