Experimenting with prototypes to enhance my understanding, I decided to test it in the console:
function Dog(){}
Dog.prototype.breed = breed;
Dog.prototype.talk = function(){
console.log('I\'m a ' + this.breed);
};
dog1 = new Dog();
dog1.breed = 'poodle';
dog1.talk();
//Here's the error message that came up...
//ReferenceError: breed is not defined
Update: I replaced null
and everything worked smoothly. Interestingly, using Dog.prototype.name = name;
actually works!
Dog.prototype.name = name;
//Dog.prototype.breed = null;
Dog.prototype.talk = function(){
console.log('my name is ' + this.name );
};
dog1 = new Dog();
dog1.name = 'charly';
//dog1.breed = 'poodle';
dog1.talk();