Skip to content

Commit ed4bbff

Browse files
committed
#23 - JavaScript
1 parent 5f9aae2 commit ed4bbff

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)