shuai-li
5/10/2019 - 12:01 AM

Constructor function with prototype

function Person(firstName, lastname, dob){
  this.firstName = firstName;
  this. lastName;
  this.dob =new Date(dob);
}

Person.prototype.getBirthYear = function(){
  return this.dob.getFullYear();
}

Person.prototype.getFullName = function(){
  return '${this.firstName} ${this.lastName}';
}

const person1 = new Person('John', 'Doe','4-3-2019')'

console.log(person1.getFullName);