Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Singleton = (function(){
- var instance;
- function Singleton() {
- if (!instance) {
- instance = this;
- } else {
- return instance;
- }
- }
- return Singleton;
- }());
- var singleton1 = new Singleton();
- var singleton2 = new Singleton();
- console.log(singleton1===singleton2);
Add Comment
Please, Sign In to add comment