I'm working through a JavaScript course and I'm curious how the code know to include an age
value above the object properties when I log it out to console? Here is the code from the lesson:
var john = {
name: 'John',
lastName: 'Smith',
yearOfBirth: 1990,
job: 'teacher',
isMarried: false,
family: ['Jane', 'Mark', 'Bob'],
calculateAge: function() {
this.age = 2016 - this.yearOfBirth;
}
};
john.calculateAge();
console.log(john);
If I understand correctly, I create an age
variable in this line:
this.age = 2016 - this.yearOfBirth;
When I look in my console, the age
property and its value are stated above the object properties. What determines this presentation?