Skip to content

Instantly share code, notes, and snippets.

@mikepack
Created April 25, 2012 06:07
Show Gist options
  • Save mikepack/2487006 to your computer and use it in GitHub Desktop.
Save mikepack/2487006 to your computer and use it in GitHub Desktop.
Decorators in JS
function SomeClass() {}
SomeClass.prototype.do_it = function() { alert('doin it!'); }
s = new SomeClass();
function Decorator(klass) { this.__proto__ = klass.__proto__; }
d = new Decorator(s)
d.do_it()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment