Skip to content

Instantly share code, notes, and snippets.

@odiak
Created April 2, 2011 01:49
Show Gist options
  • Save odiak/899151 to your computer and use it in GitHub Desktop.
Save odiak/899151 to your computer and use it in GitHub Desktop.
Object.prototype._new_ = function () {
var args = Array.apply([], arguments);
return eval("new this(" + args.join(",") + ")");
};
// sample
Array._new_(1,2,3); // [1,2,3]
Object._new_(); // {}
Number._new_(33); // 33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment