JavaScript Array toLocaleString() method
returns a string representing the elements of the array; the elements are converted to strings using their toLocaleString methods

toLocaleString() method returns a string representing the elements of the array in a particular locale.

syntax

toLocaleString(locales, options)

locales (optional). A string with a BCP 47 language tag, or an array of such strings.

If this parameter is not provided, the host environment's current locale will be used.

options (optional). An object with configuration properties.

The current locale is based on the language settings of the browser.

toLocaleString() method when used on sparse arrays iterates empty slots as if they have the value undefined.

If a locale identifier is not a string or an object, TypeError is thrown.

If a locale identifier is a string that's syntactically invalid, RangeError is thrown.

syntax 1 description
return a string representing the elements of myArray in the default locale
myArray.toLocaleString()
syntax 2 description
return a string representing the elements of myArray in selected locale
myArray.toLocaleString(locales)
syntax 3 description
return a string representing the elements of myArray in selected locale with selected options
myArray.toLocaleString(locales, options)