JavaScript Object toLocaleString() method
returns a string representing this object.
This method is meant to be overridden by derived objects for locale-specific purposes

Object.toLocaleString() method returns a string representing this object.

Object.toLocaleString() method is meant to be overridden by derived objects for locale-specific purposes.

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

No parameters are expected. However, all objects that override this method are expected to accept at most two parameters, corresponding to locales and options.

syntax

Object.toLocaleString() method can take two parameters ↴

locales (optional). A convention or formatting based on particular geography.

options (optional). An object with configuration properties.

This function is provided to give objects a generic Object.toLocaleString() method, even though not all may use it. In the core language, these built-in objects override Object.toLocaleString() to provide locale-specific formatting ↴

Array.prototype.toLocaleString

Number.prototype.toLocaleString

Date.prototype.toLocaleString

TypedArray.prototype.toLocaleString

BigInt.prototype.toLocaleString

The results provided by Object.toLocaleString() can be customized using the options argument.

Object.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.

The base Object.toLocaleString() method simply calls toString().

syntax 1 description
return a string representing myObject in the default locale
myObject.toLocaleString()
syntax 2 description
return a string representing myObject in selected locale
myObject.toLocaleString(locales)
syntax 3 description
return a string representing myObject in selected locale and with selected options applied
myObject.toLocaleString(locales, options)