Created
November 11, 2010 17:38
-
-
Save kkaefer/672868 to your computer and use it in GitHub Desktop.
instantiate with .call/apply
This file contains hidden or 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
> function Class(param) { if (!param) console.log('fail'); } | |
> new Class | |
fail | |
{} | |
> x = {}; | |
{} | |
> x.__proto__ = Class.prototype; | |
{} | |
> x instanceof Class | |
true | |
> Class.call(x, 'bar'); | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment