JavaScript Array toLocaleString() MethodThe toLocaleString() method creates a string that represents the elements of an array. It converts the array elements into the string. SyntaxParameterarray: 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. ReturnIt creates and returns a string that represents the array elements. JavaScript toLocaleString() ExampleLet's see the below examples to understand better: Example1 Here's an example that shows the basic implementation of toLocaleString() method. Test it NowOutput: The output is shown below: In the output, the array is represented in the form of string. Example2 Here's an example that implements date() method with toLocaleMethod(). Test it NowOutput: Example3 Implementing the above example on the console. Test it NowOutput: Example4 Implementing an example that combines the array elements and a value together into a new array. Test it NowOutput: The output comes out as:
Next TopicJavaScript Array
|