Here you can find the source of popCount()
//DEBUG PURPOSES ONLY Number.prototype.popCount = function() { var v = this.valueOf(); v = v - ((v >> 1) & 0x55555555); // put count of each 2 bits into those 2 bits v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // put count of each 4 bits into those 4 bits return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; };
Number.prototype.ordinalize = function() { var abs = Math.abs(this); if (abs % 100 >= 11 && abs % 100 <= 13) { return this + 'th'; abs = abs % 10; if (abs === 1) { return this + 'st'; } if (abs === 2) { return this + 'nd'; } if (abs === 3) { return this + 'rd'; } ...
function parseNumber(x){ if(!isNaN(x)) return x; return parseFloat(x.substring(1, x.length - 1));
Number.prototype.percentage = function(val){ return this * (val/100); };
Number.prototype.plural = function (a, b, c) if (this % 1) return b var v = Math.abs(this) % 100 if (11 <= v && v <= 19) return c v = v % 10 if (2 <= v && v <= 4) ...
Number.prototype.pluralA = function (ary) return this.plural(ary[0], ary[1], ary[2])
Number.prototype.powerOf = function(power) { return Math.pow(this, power); };
Number.prototype.randStr = function() { var alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var res = ''; for(var i = 0; i < this; i++) { res += alpha[Math.floor(Math.random() * alpha.length)]; return res;
Number.prototype.range = function (a, b, i) { i = i || true; var min = Math.min.apply(Math, [a, b]), max = Math.max.apply(Math, [a, b]); return i ? this >= min && this <= max : this > min && this < max; };
Number.prototype.repeat = function(n){ return this.toString().repeat(n);