Skip to content

Instantly share code, notes, and snippets.

@kkaefer
Created November 11, 2010 17:38
Show Gist options
  • Save kkaefer/672868 to your computer and use it in GitHub Desktop.
Save kkaefer/672868 to your computer and use it in GitHub Desktop.
instantiate with .call/apply
> 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