我想改变标准Date对象的行为.0..99传递给构造函数之间的年份应解释为fullYear(无添加1900).但我的以下功能不起作用
var oDateConst = Date.prototype.constructor; // save old contructor
Date.prototype.constructor = function () {
var d = oDateConst.apply(oDateConst, arguments); // create object with it
if ( ((arguments.length == 3) || (arguments.length == 6))
&& ((arguments[0] < 100) && (arguments[0] >= 0))) {
d.setFullYear(arguments[0]);
}
return d;
}
Run Code Online (Sandbox Code Playgroud)
它为什么永远不会被召唤?你会如何解决这个问题?