const mark = {
firstName: `Mark`,
lastName: `Miller`,
fullName: this.firstName + this.lastName,
weight: 78,
height: 1.69
};
console.log(mark.fullName); // the result in console: NaN
const mark = {
firstName: `Mark`,
lastName: `Miller`,
fullName: function(){
return this.firstName + this.lastName;
},
weight: 78,
height: 1.69
};
console.log(mark.fullName());
Alternate:
const mark = ({
firstName: `Mark`,
lastName: `Miller`,
init: function(){
this.fullName = this.firstName + this.lastName;
},
weight: 78,
height: 1.69
}).init();
console.log(mark.fullName);