var rahul = {
name: 'Rahul',
lastName: 'Kumar',
yearOfBirth: 1990,
calculateAge: function() {
return 2018 - this.yearOfBirth;
}
}
console.log(rahul.calculateAge());
// output : 31
var rahul = {
name: 'Rahul',
lastName: 'Kumar',
yearOfBirth: 1990,
calculateAge: () => {
return 2018 - this.yearOfBirth;
}
}
console.log(rahul.calculateAge());
// Output : NaN