Prototype to the Rescue


Nothing wrong, I'm just curious what is the difference of buddy.bark() vs buddy.bark //without the parenthesis?
Why does it print with the parenthesis but not without, but it still lets me pass the exercise?

function Dog (breed) {
  this.breed = breed;

// here we make buddy and teach him how to bark
var buddy = new Dog("golden Retriever");
Dog.prototype.bark = function() {

// here we make snoopy
var snoopy = new Dog("Beagle");
/// this time it works!


buddy.bark is an expression. buddy.bark() is a statement. Nothing happens in the former. The parens are what invokes the method.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.