Created
October 30, 2013 11:31
-
-
Save iegorov/7231155 to your computer and use it in GitHub Desktop.
Паттерн повторного использования кода на классах 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 Parent(name) { | |
this.name = name || 'Adam'; | |
} | |
Parent.prototype.say = function() { | |
return this.name; | |
}; | |
function Child(name) { | |
Parent.apply(this, arguments); | |
} | |
var kid = new Child('Patrick'); | |
console.log(kid.name); // 'Patrick' | |
typeof kid.say; // 'undefined' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment