How to extend the Javascript Date object?

前端 未结 12 2101
失恋的感觉
失恋的感觉 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:37

    In ES6, it will be possible to subclass built-in constructors (Array, Date, and Error) - reference

    Problem is there is no way to do this with current ES5 engines, as Babel indicates and will require a browser with native ES6 support.

    The current ES6 browser support for subclassing is pretty weak / non-existant as of today (2015-04-15).

提交回复
热议问题