I am learning Javascript and prototypical inheritance and haven't really gotten my head around it.
Example:
function Person(firstname) {
  this.firstname = firstname;
  this.greet1 = function() {
    console.log('Hi ' + this.firstname);
  };
};
Person.prototype.greet = function() {
  console.log('Hi ' + this.firstname);
};
var John = new Person('John');
john.greet();
john.greet1();
Both greet and greet1 give me the same result. So what is the difference and why would you use the prototype?
 
     
     
     
    