-
-
Save DavidBruant/1400408 to your computer and use it in GitHub Desktop.
an attempt to make the new operator dynamically invokeable
This file contains 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 characters
// Requires a native Function.prototype.bind (IE9+, FF4+, Chrome, Opera 12, no Safari) | |
function newOperator(constructor, args) { | |
var params = [undefined].concat(args) | |
var cst = Function.prototype.bind.apply(constructor, params); | |
return new cst(); | |
} |
It should be
(new (Function.prototype.bind.apply(Date, [window, 1995, 11, 24]))).toUTCString()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh, nice. this works:
if only it were cross-platform...