I would like a kind of wrapper for the default Date object in JavaScript so that whenever I have something like var a = new Date();, I want to execute some particular code in the constructor.
I basically want to have my own Date class that needs to be invoked whenever a call is made to Date() rather than the native code.
You need to save the reference for the native
Dateobject, than make your own wrapper, which invokes the nativeDatethen mutates it, or adds additional behavior.However, I wouldn’t mess with native objects.