Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Created December 19, 2010 19:58
Show Gist options
  • Save michaelficarra/747650 to your computer and use it in GitHub Desktop.
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
var F = function(){};
F.prototype = klass.prototype;
var o = new F();
klass.apply(o,arguments)
return o;
@dbrans
Copy link

dbrans commented Feb 6, 2011

Hey Michael, when would you use this?

@michaelficarra
Copy link
Author

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