Created
October 6, 2017 16:49
-
-
Save notalentgeek/93343e519de6f28f6043b75b364036b0 to your computer and use it in GitHub Desktop.
Revisions
-
notalentgeek created this gist
Oct 6, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ var anyton = function (ton, parameters, init_count) { if (!init_count) { init_count = 1; // Singleton. } var instances = []; this.create_instance = function () { if (instances.length < init_count) { instances.push(new ton(...parameters)); // No pun intended. } return instances[instances.length - 1]; }; }; var dummy_object = function () {}; dummy_object = new anyton(dummy_object, []); var a = dummy_object.create_instance(); var b = dummy_object.create_instance(); console.log(a === b);