Ad
Code
Diff
  • let obj = {};
    
    let Singleton = function(){
      return obj;
    };
    
    • let Singleton = (function () {
    • let instance;
    • let obj = {};
    • return function Construct_singletone () {
    • if (instance) {
    • return instance;
    • }
    • if (this && this.constructor === Construct_singletone) {
    • instance = this;
    • } else {
    • return new Construct_singletone();
    • }
    • }
    • }());
    • let Singleton = function(){
    • return obj;
    • };