Skip to content

Instantly share code, notes, and snippets.

@iegorov
Created October 30, 2013 10:14
Show Gist options
  • Save iegorov/7230158 to your computer and use it in GitHub Desktop.
Save iegorov/7230158 to your computer and use it in GitHub Desktop.
classical code reuse pattern #2
function Article() {
this.tags = ['js', 'css'];
}
Article.prototype.printTagsList = function() {
console.log( this.tags.join(', '));
};
var article = new Article();
function BlogPost() {}
BlogPost.prototype = article;
var blog = new BlogPost();
function StaticPage() {
Article.call(this);
}
var page = new StaticPage();
blog.printTagsList();
page.printTagsList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment