The toLocaleString() method creates a string that represents the elements of an array. It converts the array elements into the string.
array: It is the given array or the source array.
Including this, there are two optional parameters also.
locales: It is a string that supports BCP 47 language tag, i.e., an IETF code that identifies human language.
Options: It is an object used for dates and numbers basically. They carry their configuration properties with them.
It creates and returns a string that represents the array elements.
Let's see the below examples to understand better:
Here's an example that shows the basic implementation of toLocaleString() method.Test it Now
The output is shown below:
In the output, the array is represented in the form of string.
Here's an example that implements date() method with toLocaleMethod().Test it Now
Implementing the above example on the console.Test it Now
Implementing an example that combines the array elements and a value together into a new array.Test it Now
The output comes out as: