How to extend the Javascript Date object?

前端 未结 12 2087
失恋的感觉
失恋的感觉 2020-12-08 14:50

I\'m trying to subclass/extend the native Date object, without modifying the native object itself.

I\'ve tried this:

    var util = require(\'util\')         


        
12条回答
  •  再見小時候
    2020-12-08 15:36

    I know this is a bit late, but for others who may encounter this issue, I manged to effectively subclass Date for a polyfill I needed for PhantomJS. The technique seems to work in other browser as well. There were a few additional issues to work out but essentially I followed the same approach as Rudu.

    The full commented code is at https://github.com/kbaltrinic/PhantomJS-DatePolyfill.

提交回复
热议问题