JSFiddle - React, Tailwind, and code Playground
JavaScript
(function (old) {
Number.prototype.toLocaleString = function () {
var n = old.apply(1000);
if (n.length == 8) // IE's implementation, good enough for us
return old.apply(this);
else if (n.length == 5) { // Fx's implementation, needs a little work
return old.apply(this).slice(0,-3) + this.toFixed(2).slice(-3);
} else { // Other implementations
var f = this.toFixed(2).slice(-3);
var s = f.substring(0,1) == "." ? "," : ".";
return this.toFixed(2).slice(0,-3).replace(/(?=(?:\d{3})+(?!\d))/g, s) + f;
}
}
})(Number.prototype.toLocaleString);
alert(10000000.12.toLocaleString());