//Object Literal
// const brad = {
// name: 'Brad',
// age: 30
// }
// console.log(brad);
// console.log(brad.age);
//Person Constructor
function Person(name, dob){
this.name = name; //this refers to current instance of the object we created
// this.age = age;
this.birthday = new Date(dob); //Date is a core object
this.calculateAge = function(){
const diff = Date.now() - this.birthday.getTime();
const ageDate = new Date(diff);
return Math.abs(ageDate.getUTCFullYear() - 1970);
}
}
// const brad = new Person('Brad', 36);
// const john = new Person('John', 30);
// console.log(john.age);
const brad = new Person('Brad', '9-10-1981');
console.log(brad.calculateAge());