diff --git a/index.html b/index.html index 4caf3e0..95d3e7a 100644 --- a/index.html +++ b/index.html @@ -37,6 +37,17 @@ console.error('Failed to load ' +filename); } } + + function instantiate(className, args) { + var o, f, c; + c = window[className]; // get reference to class constructor function + f = function(){}; // dummy function + f.prototype = c.prototype; // reference same prototype + o = new f(); // instantiate dummy function to copy prototype properties + c.apply(o, args); // call class constructor, supplying new object as context + o.constructor = c; // assign correct constructor (not f) + return o; + } var QueryString = function () { // This function is anonymous, is executed immediately and @@ -71,9 +82,9 @@