Standard built-ins
Intl.ListFormat.prototype.formatToParts()
Return element and literal parts for an iterable of strings.
Formal Syntax & Structure
javascript syntaxjavascript
formatter.formatToParts([list])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| list | Iterable<String> | Strings in display order. |
Return Value
Array
Labeled list pieces.
Working Example
Example Snippetjavascript
console.log(new Intl.ListFormat("en-US").formatToParts(["x","y"]).filter(p=>p.type==="element").length);