let person={
firstName: 'Joe',
lastname :'dawn',
birthYear: 1995,
job:"IT",
family:['nikita','papa','mom'],
age:(function(){
console.log(this);
return new Date().getFullYear()- this.birthYear;
})()
};
When I am printing the age it is giving me NaN
as the this.birthYear
is giving undefined
as a result.
The question is how can I call the function within the object and use the property of that object only in the function.