Option 1: Using the two functions of closure, the internal variables can be read flexibly, and the second is to keep these variables in the memory.
//Option 1
var SingletonTester = (function { Another way is to return the object
this.pointX = args.pointX || 6;
this.pointY = args.pointY || 10;
}
//Single instance
var instance;
//return object
return {
name: 'SingletonTester',
getInstance: function (args) {
if (instance = == undefined) {
instance = new Singleton(args);
})(); //Execute this method directly
//Test
var test = SingletonTester.getInstance({ pointX: 5 });
console.log(test.pointX);
Option 2: