(new Double(3)).compareTo(new Double(4)) fails. This is necessary for using Double(x) as a key in a Hashtable. My solution: Number.prototype.compareTo = function(x) { var a = this.valueOf(), b = x.valueOf(); return (a < b ? -1 : a == b ? 0 : 1) };