Форматирование суммы (числа)
const amount = 5500.67;
const en = new Intl.NumberFormat("en", {style: "decimal"}).format(amount);
const ru = new Intl.NumberFormat("ru", {style: "decimal"}).format(amount);
const de = new Intl.NumberFormat("de", {style: "decimal"}).format(amount);
console.log(en); // 5,500.67
console.log(ru); // 5 500,67
console.log(de); // 5.500,67
Форматирование процентов
const value = 0.851;
const en = new Intl.NumberFormat("en", {style: "percent"}).format(value);
const ru = new Intl.NumberFormat("ru", {style: "percent"}).format(value);
const tr = new Intl.NumberFormat("tr", {style: "percent"}).format(value);
console.log(en); // 85%
console.log(ru); // 85 %
console.log(tr); // %85
Вывод дробной части
const value = 0.851;
const en = new Intl.NumberFormat("en", {style: "percent", minimumFractionDigits: 2}).format(value);
const ru = new Intl.NumberFormat("ru", {style: "percent", minimumFractionDigits: 2}).format(value);
console.log(en); // 85.10%
console.log(ru); // 85,10 %
minimumFractionDigits задаёт количество знаков после запятой.
Форматирование валюты
const value = 85.1;
const usd = new Intl.NumberFormat("ru", {style: "currency", currency: "USD"}).format(value);
const euro = new Intl.NumberFormat("ru", {style: "currency", currency: "EUR"}).format(value);
const rub = new Intl.NumberFormat("ru", {style: "currency", currency: "RUB"}).format(value);
console.log(usd); // 85,10 $
console.log(euro); // 85,10 €
console.log(rub); // 85,10 ₽
По умолчанию выводится символ валюты, однако значение currencyDisplay: "name" позволяет вывести локализованное название валюты:
const value = 85;
const usd = new Intl.NumberFormat("ru", {style: "currency", currency: "USD", currencyDisplay: "name", minimumFractionDigits: 0}).format(value);
const euro = new Intl.NumberFormat("ru", {style: "currency", currency: "EUR", currencyDisplay: "name"}).format(value);
const rub = new Intl.NumberFormat("ru", {style: "currency", currency: "RUB", currencyDisplay: "name"}).format(value);
console.log(usd); // 85 долларов США
console.log(euro); // 85,00 евро
console.log(rub); // 85,00 российского рубля
Форматирование единиц измерения
const value = 85;
const longLiter = new Intl.NumberFormat("ru", {style: "unit", unit: "liter", unitDisplay: "long"}).format(value);
const shortLiter = new Intl.NumberFormat("ru", {style: "unit", unit: "liter", unitDisplay: "short"}).format(value);
console.log(longLiter); // 85 литров
console.log(shortLiter); // 85 л
Еще несколько примеров с форматированием разных единиц измерения:
const value = 85;
const kilobyte = new Intl.NumberFormat("ru", {style: "unit", unit: "kilobyte", unitDisplay: "long"}).format(value);
const meter = new Intl.NumberFormat("ru", {style: "unit", unit: "meter", unitDisplay: "long"}).format(value);
const gram = new Intl.NumberFormat("ru", {style: "unit", unit: "gram", unitDisplay: "long"}).format(value);
console.log(kilobyte); // 85 килобайт
console.log(meter); // 85 метров
console.log(gram); // 85 грамм
Lynell
22/2/2023 18:01
Hello, MegaLeadsTree.com is shutting down. We have made available all our leads in 145 countries at a one-time fee. Visit us on MegaLeadsTree.com.
Loren
2/4/2023 16:27
DataList2023.com
Дмитрий
17/6/2023 19:50
Приветствую! Готов купить ваш сайт codemg.ru, в том числе по цене выше рыночной. Меня зовут Дмитрий Купрацевич. В теме сайтов более 5 лет. Занимался улучшением более 50 проектов. Ищу качественные проекты, как ваш, чтобы продолжить их развитие. Связь через Телеграм kupratsevich, почту kupdimsites@gmail.com, whatsapp (+79959176538).
Demetra
20/6/2023 2:58
It is with sad regret we are shutting down. We have made all our leads available for a one time fee on DataList2023.com Regards, Demetra
Lisa
10/1/2024 12:37
Hello, MarketGirl.biz has made available our Google Maps Database for everyone. I am shutting down the company to spend more time with my family. I wish you a prosperous new year! Lisa Cooper MarketGirl.biz
Karri
30/1/2024 4:43
Hey! Come test out our beta project LeadsFly.biz and come get your free business leads. Regards, Karri
Mikki
7/5/2024 4:27
Hi, We are a provider of premium databases for companies. I want to know if you need any sort of data for your business? Please respond to this email and let us know what you are looking for. Regards Jannes
Ricky
15/7/2024 20:42
Hello, It is with sad regret that after 12 years, LeadsMax.biz is shutting down. We have made all our databases available on our website. 25 Million companies 527 Million People LeadsMax.biz
Felica
20/8/2024 0:40
Hello It is with sad regret to inform you that PCXLeads.com is shutting down We have made all our databases available to the public. Search your codemg.ru, industry, phone numbers, emails, people.. 25 Million Companies globally 500 Million Professionals 143 Countries Included Get all this in our shutting down special for $149 Regards, PCXLeads.com
Suzanne
20/9/2024 20:02
We are proud to present our latest product for business data Experience our searches on worldwide b2b data This offer is a comprehensive dataset of each country Which are all kept up to date on a monthly basis Try out the open search we offer to see the full extent of our dataset You can never have enough leads LeadsBox.biz
Оставить комментарий
Заполните все поля.