Skip to content

Instantly share code, notes, and snippets.

@royling
Created August 18, 2015 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save royling/89c1621740286771e98b to your computer and use it in GitHub Desktop.
Save royling/89c1621740286771e98b to your computer and use it in GitHub Desktop.
function superhero(clazz) {
Object.defineProperty(clazz.prototype, 'isSuperHero', {value: true});
return clazz;
}
@superhero
class MySuperHero {
constructor(first, last) {
this.name = `${first} ${last}`;
}
}
let batman = new MySuperHero('Bruce', 'Wayne');
console.log(`${batman.name} is a super hero? ${batman.isSuperHero}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment