Commit a8d9c578 authored by MohammadAli Keshavarz's avatar MohammadAli Keshavarz

learning how to add method to function constructor

parent 9b541197
......@@ -12,7 +12,11 @@ var Person = function(name, yearOfBirth, job) {
this.name = name;
this.yearOfBirth = yearOfBirth;
this.job = job;
this.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