3 ms·
There's also the equivalent Date.now() (as of ES5). If you'd like to write test code that overrides the current Date, this is the easiest version to override.
by altano 16y ago
There's also the equivalent Date.now() (as of ES5). If you'd like to write test code that overrides the current Date, this is the easiest version to override. Monkey-patching Date's constructor is a disaster. Plus, backwards compatibility can easy be added (see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/now https://developer.mozilla.org/en/JavaScript/Reference/Global...) to non-ES5-compliant browsers.