var d = Date.prototype;
Object.defineProperty(d, "Year", {
get: function() {return this.getFullYear() },
set: function(y) { this.setFullYear(y) }
});
Above code add property in Date object. This is use of getter and setter in a Date
object: Shown in below lines of code.
var now = new Date;
document.write(now.Year + '<br/>'); // 2015
now.Year = 2016;
document.write(now);
// Sat Apr 16 2016 13:56:25 GMT+0500 (Pakistan Standard Time)