Created
November 4, 2016 10:55
-
-
Save olivier-spinelli/e6a1c54b361f41ccc6f1d933f75cf741 to your computer and use it in GitHub Desktop.
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 Animal( objectName ) { | |
this._name = objectName; | |
} | |
Animal.prototype._name = "Animal’s prototype."; | |
Animal.prototype.makeNoise = function () { console.log( this._name + ' is silent.' ); }; | |
Animal.prototype.run = function () { console.log( this._name + ' runs.' ); }; | |
var a = new Animal( "Basic Animal." ); | |
a.makeNoise(); | |
function Dog( objectName ) { | |
this._name = objectName; | |
} | |
Dog.prototype = new Animal( "Dog’s prototype." ); | |
Dog.prototype.makeNoise = function () { console.log( this._name + ' is barking.' ); }; | |
//var pAnimal = Animal.prototype; | |
//delete pAnimal.run; | |
delete Animal.prototype.run; | |
//Animal.prototype = Dog.prototype; | |
var m = new Dog( "Médor" ); | |
m.makeNoise(); | |
m.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment