11
重载JavaScript中的算术运算符?
给定这个JavaScript“类”定义,这是我想到这个问题的最佳方式: var Quota = function(hours, minutes, seconds){ if (arguments.length === 3) { this.hours = hours; this.minutes = minutes; this.seconds = seconds; this.totalMilliseconds = Math.floor((hours * 3600000)) + Math.floor((minutes * 60000)) + Math.floor((seconds * 1000)); } else if (arguments.length === 1) { this.totalMilliseconds = hours; this.hours = Math.floor(this.totalMilliseconds / 3600000); this.minutes …