JSFiddle - React, Tailwind, and code Playground
JavaScript
//Add a variable to all Date objects
Date.prototype.done = false;
//Override the getFullYear function
Date.prototype.getFullYear = (function(){
//Store a reference to the native function
var $gfy = Date.prototype.getFullYear;
return function(){
//Have we hit this routine before?
if (!this.done) {
//We've hit this routine once so flag it.
this.done = true;
//Execute native funciton, then add 150
return $gfy.call(this)+150;
} else {
//Call the native function from now on.
return $gfy.call(this);
}
}
}());//self executing function so it executes as soon as it is evaluated.
var date = new Date();
//Will return +150 the first time
alert(date.getFullYear());
//After that execute the default
//function for'getFullYear'
alert(date.getFullYear());