What is `Intl.NumberFormat` used for and what does `new Intl.NumberFormat(‘en-US’, {style:’currency’, currency:’USD’}).format(1234.56)` produce?

JavaScript Developer Hard

JavaScript Developer — Hard

What is `Intl.NumberFormat` used for and what does `new Intl.NumberFormat(‘en-US’, {style:’currency’, currency:’USD’}).format(1234.56)` produce?

Key points

  • `Intl.NumberFormat` is for locale-sensitive number formatting
  • The code formats the number as currency in US locale
  • Correctly displays currency symbol, separators, and decimal places

Ready to go further?

Related questions