Intl.NumberFormat Unit

MDN Link for Intl.NumberFormat

Browser Support

Input values

Alternative use

Intl.NumberFormat can also be used from Number.prototype.toLocaleString() const numberToFormat = 123456.789;
const formatted = numberToFormat.toLocaleString("en-US");
// 123,456.789 deg

Output

unitDisplay

{ style: "unit" , unit: "degree" , unitDisplay: "short" , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , unitDisplay: "long" , }
// 123,456.789 degrees
{ style: "unit" , unit: "degree" , unitDisplay: "narrow" , }
// 123,456.789°

compactDisplay

{ style: "unit" , unit: "degree" , compactDisplay: "short" , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , compactDisplay: "long" , }
// 123,456.789 deg

notation

{ style: "unit" , unit: "degree" , notation: "standard" , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , notation: "scientific" , }
// 1.235E5 deg
{ style: "unit" , unit: "degree" , notation: "engineering" , }
// 123.457E3 deg
{ style: "unit" , unit: "degree" , notation: "compact" , }
// 123K deg

signDisplay

{ style: "unit" , unit: "degree" , signDisplay: "auto" , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , signDisplay: "never" , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , signDisplay: "always" , }
// +123,456.789 deg
{ style: "unit" , unit: "degree" , signDisplay: "exceptZero" , }
// +123,456.789 deg

useGrouping

{ style: "unit" , unit: "degree" , useGrouping: true , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , useGrouping: false , }
// 123456.789 deg

minimumIntegerDigits

{ style: "unit" , unit: "degree" , minimumIntegerDigits: 1 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumIntegerDigits: 2 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumIntegerDigits: 3 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumIntegerDigits: 4 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumIntegerDigits: 5 , }
// 123,456.789 deg

minimumFractionDigits

{ style: "unit" , unit: "degree" , minimumFractionDigits: 1 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumFractionDigits: 2 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumFractionDigits: 3 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumFractionDigits: 4 , }
// 123,456.7890 deg
{ style: "unit" , unit: "degree" , minimumFractionDigits: 5 , }
// 123,456.78900 deg

maximumFractionDigits

{ style: "unit" , unit: "degree" , maximumFractionDigits: 1 , }
// 123,456.8 deg
{ style: "unit" , unit: "degree" , maximumFractionDigits: 2 , }
// 123,456.79 deg
{ style: "unit" , unit: "degree" , maximumFractionDigits: 3 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , maximumFractionDigits: 4 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , maximumFractionDigits: 5 , }
// 123,456.789 deg

minimumSignificantDigits

{ style: "unit" , unit: "degree" , minimumSignificantDigits: 1 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumSignificantDigits: 2 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumSignificantDigits: 3 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumSignificantDigits: 4 , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , minimumSignificantDigits: 5 , }
// 123,456.789 deg

maximumSignificantDigits

{ style: "unit" , unit: "degree" , maximumSignificantDigits: 1 , }
// 100,000 deg
{ style: "unit" , unit: "degree" , maximumSignificantDigits: 2 , }
// 120,000 deg
{ style: "unit" , unit: "degree" , maximumSignificantDigits: 3 , }
// 123,000 deg
{ style: "unit" , unit: "degree" , maximumSignificantDigits: 4 , }
// 123,500 deg
{ style: "unit" , unit: "degree" , maximumSignificantDigits: 5 , }
// 123,460 deg

localeMatcher

{ style: "unit" , unit: "degree" , localeMatcher: "best fit" , }
// 123,456.789 deg
{ style: "unit" , unit: "degree" , localeMatcher: "lookup" , }
// 123,456.789 deg