Skip to content

Instantly share code, notes, and snippets.

@jiggliemon
Created August 16, 2011 02:36
Show Gist options
  • Save jiggliemon/1148331 to your computer and use it in GitHub Desktop.
Save jiggliemon/1148331 to your computer and use it in GitHub Desktop.
if (!Function.prototype.construct)
Function.prototype.construct = function(aArgs) {
if (aArgs.constructor !== Array)
throw new TypeError("second argument to Function.prototype.construct must be an array");
var aBoundArgs = Array.prototype.concat.apply([null], aArgs),
fBound = this.bind.apply(this, aBoundArgs);
return new fBound();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment