Skip to content

Instantly share code, notes, and snippets.

@halcarleton
Last active December 6, 2016 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halcarleton/06f72f3993bac1837f305c41216cf051 to your computer and use it in GitHub Desktop.
Save halcarleton/06f72f3993bac1837f305c41216cf051 to your computer and use it in GitHub Desktop.
call/apply with `new` operator
function applyNew(constructor, args) {
return new (Function.prototype.bind.apply(constructor, [constructor].concat(args)))();
}
function callNew(func /*[, arg1[, arg2[, ...]]]*/) {
return applyNew(func, ...arguments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment