JS: Intl.NumberFormat
for examples, see JS: Number .prototype .toLocaleString
Intl.NumberFormat-
console.log(new Intl.NumberFormat("en-US").format(2418.5335)); // 2,418.534 // or sans new console.log(Intl.NumberFormat("en-US").format(2418.5335)); // 2,418.534
const xf = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", minimumFractionDigits: 2, }); console.log(xf.format(4812.84)); // $4,812.84 // Format as Indian currency (Lakh/Crore system) const xformat_indian = new Intl.NumberFormat("en-IN", { style: "currency", currency: "INR", }); console.log(xformat_indian.format(2745.9071)); // ₹2,745.91
Static methods
Intl.NumberFormat.supportedLocalesOf- Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.
Instance properties
Intl.NumberFormat.prototype.constructor
Instance methods
Intl.NumberFormat.prototype.formatIntl.NumberFormat.prototype.formatRangeIntl.NumberFormat.prototype.formatRangeToPartsIntl.NumberFormat.prototype.formatToPartsIntl.NumberFormat.prototype.resolvedOptions