formatArray()function

formatArray(arr: ImmutableArray<unknown>, options?: ArrayFormatOptions, caller: AnyCaller = formatArray): string
ParamType
arrImmutableArray<unknown>
Array of values to format. required
optionsArrayFormatOptions
Formatting options passed through to Intl.ListFormat.
callerAnyCaller
Function to attribute a thrown error to (defaults to formatArray itself). Defaults to formatArray
Return
string
Locale-formatted list string with each item converted via formatValue().

Format an unknown array as a string.

Examples

formatArray(["a", "b", "c"]) // "a, b, and c"