// Constructor function
function Person(name, age, gender) {
this.name = name;
this.age = age;
this.gender = gender;
this.talk = function () {
alert(this.name + ' says Hello! \n I\'m ' + this.age);
}
}
Person.prototype.reduceAge = function(by){
this.age = this.age-by;
}
var personA = new Person('Adam', 30, 'Male'); // instance of Person
var personB = new Person('Eve', 29, 'Female'); // another instance of person
personA.reduceAge(2); // would reduce the age by 2. eg: 30-2=28;
personA.talk(); // Will alert "Adam says Hello! I'm 28"
personB.talk(); // Will alert "Eve says Hello! I'm 29"