felgall — 2011-10-06T16:12:09-04:00 — #1
Is there any way at all to create a new template object that inherits from the built in Date object so as to be able to add new methods to that child object without adding them to the built in Date object? I've tried everything I can think of and as far as I can tell it keeps referencing the Date function instead of the Date object and so doesn't work.
logic_ali — 2011-10-06T21:25:21-04:00 — #2
I'm not sure if I've understood and I'm not saying there isn't some fatal fallacy associated with it, but does this fit the bill?
Object.prototype.MyDate = Date;
Object.MyDate.prototype.showTime = function()
alert( this.getTime() ); /* Method inherited from Date */
md = new Object.MyDate();
alert( Date.showTime ); /* undefined so has not affected Date object */
felgall — 2011-10-07T02:18:01-04:00 — #3
If that works then it is adding extra methods to all objects where what I am trying to do is to avoid adding extra methods to all Dates and just add them to specific dates
felgall — 2011-10-07T04:52:17-04:00 — #4
I still don't like how messy it is in actually getting the built in date methods to work so if anyone has any suggestions for a workable alternative.
At least I achieved my intended objective of not adding the extra methods to the Date object.