Created
December 19, 2010 19:58
-
-
Save michaelficarra/747650 to your computer and use it in GitHub Desktop.
instantiating a member of a class with a variable number of constructor arguments
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
var F = function(){}; | |
F.prototype = klass.prototype; | |
var o = new F(); | |
klass.apply(o,arguments) | |
return o; |
When you need to instantiate a member of a class with a variable number of arguments given to the constructor. I used it in one of my projects that lazily loaded classes when they were used. The lazy constructor had to be able to take any number of arguments and pass them through to the real constructor once it was loaded.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Michael, when would you use this?