Singleton Design Pattern
var Singleton = (function(){ var repo; var createRepo = function (){ return new Object("Singleton"); } var getInstance = function (){ if(!repo){ repo = createRepo(); } return repo; } return { getInstance: getInstance } }()) var s1 = Singleton.getInstance(); var s2 = Singleton.getInstance(); if(s1 === s2){ console.log("Same") }