Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b9446d3
Intl.NumberFormat - flyby fixes
hamishwillee Jul 12, 2022
bb388ae
Intl.NumberFormat.formatRange() is experimental
hamishwillee Jul 12, 2022
fb5ad81
Apply suggestions from code review
hamishwillee Jul 12, 2022
870407e
Intl.PluralRules.selectRange() is experimental
hamishwillee Jul 12, 2022
5341b2c
Merge branch 'intl_numberformat_flyby' of https://github.com/hamishwi…
hamishwillee Jul 12, 2022
311069d
Update files/en-us/web/javascript/reference/global_objects/intl/numbe…
hamishwillee Jul 12, 2022
1e0c7e8
NumberFormat.resolvedOptions() - link to the actual options
hamishwillee Jul 12, 2022
339a747
Add information about formatRangeToParts() source property in returne…
hamishwillee Jul 12, 2022
ee1e843
formatRange/formatRangeToParts can throw range error
hamishwillee Jul 12, 2022
35bb2b4
NumberFormat.format() - add info on string handlign
hamishwillee Jul 12, 2022
ea804f0
Update index.md
Josh-Cena Jul 12, 2022
b2712f5
Update index.md
Josh-Cena Jul 12, 2022
600c399
Merge branch 'main' into intl_numberformat_flyby
hamishwillee Jul 18, 2022
3d5fcca
format() clarify string format
hamishwillee Jul 18, 2022
14a16d4
Update files/en-us/web/javascript/reference/global_objects/intl/numbe…
hamishwillee Jul 18, 2022
51cfe41
Update files/en-us/web/javascript/reference/global_objects/intl/numbe…
hamishwillee Jul 18, 2022
fb6033b
Update files/en-us/web/javascript/reference/global_objects/intl/numbe…
hamishwillee Jul 18, 2022
efc0a37
Update files/en-us/web/javascript/reference/global_objects/intl/numbe…
hamishwillee Jul 18, 2022
d1477d4
Update files/en-us/web/javascript/reference/global_objects/intl/numbe…
hamishwillee Jul 18, 2022
3306d17
Update files/en-us/web/javascript/reference/global_objects/intl/numbe…
hamishwillee Jul 18, 2022
1e9a580
formatrangetoparts - fix up return section
hamishwillee Jul 18, 2022
a55b388
Merge branch 'intl_numberformat_flyby' of https://github.com/hamishwi…
hamishwillee Jul 18, 2022
a87bcb3
resolvedOptions - put options into return value
hamishwillee Jul 18, 2022
6c4971c
Numerous minor layout changes
hamishwillee Jul 18, 2022
273d63c
Apply suggestions from code review
hamishwillee Jul 18, 2022
a7feb57
Fix using format anglicization
hamishwillee Jul 18, 2022
62729c4
Layout changes for consistency
hamishwillee Jul 18, 2022
558cd4e
Update files/en-us/web/javascript/reference/global_objects/intl/numbe…
hamishwillee Jul 18, 2022
87f9adf
Update files/en-us/web/javascript/reference/global_objects/intl/numbe…
hamishwillee Jul 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ formatters.
## Syntax

```js
formatRangeToParts()
formatRangeToParts(startRange, endRange)
```

Expand All @@ -38,6 +37,11 @@ formatRangeToParts(startRange, endRange)

An {{jsxref("Array")}} of objects containing the formatted range of numbers in parts.

### Exceptions

- `TypeError`
- : Either `startRange` or `endRange` is undefined.

## Description

The `formatRangeToParts()` method is useful when custom formatting ranges of number
Expand All @@ -58,39 +62,36 @@ locale-specific parts. The structure of the array the `formatRangeToParts()` met

Possible types are the following:

- currency
- : The currency string, such as the symbols "$" and "€" or the name "Dollar", "Euro",
depending on how `currencyDisplay` is specified.
- decimal
- `currency`
- : The currency string, such as the symbols "$" and "€" or the name "Dollar", "Euro", depending on how `currencyDisplay` is specified.
- `decimal`
- : The decimal separator string (".").
- fraction
- `fraction`
- : The fraction number.
- group
- `group`
- : The group separator string (",").
- infinity
- `infinity`
- : The {{jsxref("Infinity")}} string ("∞").
- integer
- `integer`
- : The integer number.
- literal
- `literal`
- : Any literal strings or whitespace in the formatted number.
- minusSign
- `minusSign`
- : The minus sign string ("-").
- nan
- `nan`
- : The {{jsxref("NaN")}} string ("NaN").
- plusSign
- `plusSign`
- : The plus sign string ("+").
- percentSign
- `percentSign`
- : The percent sign string ("%").
- unit
- : The unit string, such as the "l" or "litres", depending on how
`unitDisplay` is specified.
- `unit`
- : The unit string, such as the "l" or "litres", depending on how `unitDisplay` is specified.

## Examples

### Comparing formatRange and formatRangeToParts

`NumberFormat` outputs localized, opaque strings that cannot be manipulated
directly:
`NumberFormat` outputs localized, opaque strings that cannot be manipulated directly:

```js
const startRange = 3500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ new Intl.NumberFormat(locales, options)
- `roundingIncrement` {{experimental_inline}}
- : Specifies the rounding-increment precision. Must be one of the following integers:
"`1`", " `2`", "`5`", "`10`", "`20`", " `25`", "`50`", "`100`", "`200`", "`250`", "`500`", "`1000`", "`2000`", "`2500`", " `5000`".

> **Note:** The `roundingIncrement` option controls the rounding increment to be used when formatting numbers:
- It indicates the increment at which rounding should take place relative to the calculated rounding magnitude.
- It cannot be mixed with significant-digits rounding or any setting of `roundingPriority` other than `auto`.
>
> - It indicates the increment at which rounding should take place relative to the calculated rounding magnitude.
> - It cannot be mixed with significant-digits rounding or any setting of `roundingPriority` other than `auto`.
>
> For example, if `maximumFractionDigits` is 2 and `roundingIncrement` is 5, then the number is rounded to the nearest 0.05 ("nickel rounding").
>
Expand All @@ -214,7 +216,6 @@ new Intl.NumberFormat(locales, options)
> ```
>
> If you set `minimumFractionDigits` and `maximumFractionDigits`, they must set them to the same value; otherwise a `RangeError` is thrown.
>

- `trailingZeroDisplay` {{experimental_inline}}
- : A string expressing the strategy for displaying trailing zeros on whole numbers. The default is "`auto`".
Expand Down