JS: Good parts - Ch.5 - Inheritance

Prototypial

by Denise Nepraunig

JavaScript

/* 
All texts and infos I have taken from:
'JavaScript: The Good Parts' by Douglas Crockford
*/

// Inheritance - Prototypial
// take an object you like and change the things
// you don't like and add your own stuff

var myMammal = {
    name: 'Herb the Mammal',
    get_name: function () {
        return this.name;
    }
};

var myCat = Object.create(myMammal);
myCat.name = 'Henrietta';
myCat.get_name = function () {
    return 'Meow, meow, I am ' + this.name + '!';
};
console.log(myCat.get_name());