Date.prototype.dateAdd = function (interval, number) {
var d = this; var k = { 'y': 'FullYear', 'q': 'Month', 'm': 'Month', 'w': 'Date', 'd': 'Date', 'h': 'Hours', 'n': 'Minutes', 's': 'Seconds', 'ms': 'MilliSeconds' }; var n = { 'q': 3, 'w': 7 }; eval('d.set' + k[interval] + '(d.get' + k[interval] + '()+' + ((n[interval] || 1) * number) + ')'); return d;
}
The above extension code is not very clear. Can someone explain it to me? ? ? The meaning of each line
d is the date object produced by new.
The entire code is just a spelling js script string and then executed.