// create a Date var type then use getFullYear. this.dob = new Date(dob); this.getBirthYear = function() { return this.dob.getFullYear(); }
const d = new Date(); d.setFullYear(2020);