Skip to content

Instantly share code, notes, and snippets.

@zet777
Created May 8, 2021 12:39
Show Gist options
  • Save zet777/f0c2e358af66b7d9055d6af15467c202 to your computer and use it in GitHub Desktop.
Save zet777/f0c2e358af66b7d9055d6af15467c202 to your computer and use it in GitHub Desktop.
Object Intl
const numberFormat = new Intl.NumberFormat('de-DE');
let out = numberFormat.format(74391351.243);
console.log(out);
out = new Intl.NumberFormat("en-US",{
style:"percent"
}).format(0.25);
console.log(out)
// Валюты
const c = 69900.60;
out = new Intl.NumberFormat('ru-RU',{
style: "currency",
currency: 'RUB'
}).format(c);
console.log(out);
// Единицы измерения
out = new Intl.NumberFormat("en-US",{
style: "unit",
unit: 'kilometer-per-hour'
}).format(35);
console.log(out);
out = new Intl.NumberFormat("ru-RU",{
style: "unit",
unit: 'liter',
unitDisplay: 'long'// полное название единицы измерения с поддержкой падежей
}).format(3);
console.log(out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment