Skip to content

Instantly share code, notes, and snippets.

@rakibulalam
Last active May 8, 2018 18:09
Show Gist options
  • Save rakibulalam/ca6762989777dd3e6b28962898bb72b6 to your computer and use it in GitHub Desktop.
Save rakibulalam/ca6762989777dd3e6b28962898bb72b6 to your computer and use it in GitHub Desktop.
Singleton Pattern in ES6
let instance;
// define instance variaible out of the scope.
export default class Single{
constructor()
{
if(!instance) // if its not defined.
{
instance=this; // let it to be filled.
}
return instnace;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment