Created
September 1, 2018 20:54
-
-
Save tatupesonen/29060ab634e3f99e285dca23d66c7704 to your computer and use it in GitHub Desktop.
What's the difference?
This file contains 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
var Person = function (name, yearOfBirth, job) { | |
this.name = name; | |
this.yearOfBirth = yearOfBirth; | |
this.job = job; | |
//This | |
this.calculateAge = function () { | |
console.log(2018 - this.yearOfBirth); | |
} | |
} | |
//versus doing this? | |
Person.prototype.calculateAge = function() { | |
console.log(2018 - this.yearOfBirth); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment