Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion example/hello-world.ts
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
console.log("Hello World")
var Singleton = (function() {

var Singleton = function() {
this.type = "0";
}
var instance = null;

var createInstance = function() {
instance = new Singleton();
return instance;
}

return {
getInstance : function() {
if(!instance) {
instance = createInstance();
}
return instance;
}
};

})();

function Client() {}

Client.prototype.test = function() {

var s1 = Singleton.getInstance();
var s2 = Singleton.getInstance();

if(s1 === s1) {
console.log("Both variables contain the same instance.");
}else{
console.log("Variables contain different instances.");
}
}

new Client().test();