Commit 5ffa77ae authored by MohammadAli Keshavarz's avatar MohammadAli Keshavarz

using prototype property

parent a8d9c578
......@@ -12,11 +12,12 @@ var Person = function(name, yearOfBirth, job) {
this.name = name;
this.yearOfBirth = yearOfBirth;
this.job = job;
this.calculateAge = function() {
console.log(2019 - this.yearOfBirth);
}
};
Person.prototype.calculateAge = function() {
console.log(2019 - this.yearOfBirth);
}
var mike = new Person("mike", 1991, "developer");
console.log(mike);
mike.calculateAge();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment