class Singleton{
private static instance: Singleton; //Propiedad de la clase
public random:number; // Propiedad del objeto
private constructor(){
this.random = Math.random();
}
public static getInstance():Singleton{
if(!this.instance){
this.instance = new Singleton();
}
return this.instance;
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter