Created
October 30, 2013 10:14
-
-
Save iegorov/7230158 to your computer and use it in GitHub Desktop.
classical code reuse pattern #2
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 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