In this question, we have a Dog
constructor function. Our dog obviously knows the speak command. What gets logged in the following example when we ask Pogo to speak?
function Dog(name) {
this.name = name;
this.speak = function() {
return 'woof';
};
}
const dog = new Dog('Pogo');
Dog.prototype.speak = function() {
return 'arf';
};
console.log(dog.speak());
A) woof
B) arf
Put your answer in the comments!
Top comments (5)
Woof
woof
It should be “woof” because dog.speak will get called and dog.proto.speak will never be searched for.
Error
woof