Skip to content

Instantly share code, notes, and snippets.

@iegorov
Created October 30, 2013 11:31
Show Gist options
  • Save iegorov/7231155 to your computer and use it in GitHub Desktop.
Save iegorov/7231155 to your computer and use it in GitHub Desktop.
Паттерн повторного использования кода на классах 2
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