toLocaleString
  • 23 May 2023
  • Dark
    Light
  • PDF

toLocaleString

  • Dark
    Light
  • PDF

Article summary

toLocaleString Task Purpose

The toLocaleString task is used to convert the elements of a given array to a locale string. The elements are often separated by a locale-specific string. The result of calling this task is similar to the toString method, except this task is locale-specific.

Potential Use Case

This task is typically used to specify a language-specific format for dates, time, numbers, objects and arrays. Let's say you need to format currency such as "USD" for the US dollar, "EUR" for the euro, or "INR" for the Indian Rupee. You could use the toLocaleString task to display the currency in the appropriate format and symbol that represents the locale that should be used.

Parameters

Input and output parameters are shown below.

Input Type Description
arr Array Required. The array to convert.
locales Array Required. A string that holds a BCP 47 language tag, or an array of such language tags. If the locales parameter is not provided or is undefined, the default locale is used.
options Object Required. An object with configuration properties. For number objects, use Number.prototype.toLocaleString(). For date objects, use Date.prototype.toLocaleString().


Output Type Description
elementString String A string representing the elements of the array.

Examples

In the IAP examples shown below:

  • All the incoming variables for toLocaleString are required.

    toLocaleString-01

  • In the examples shown below, toLocaleString is used to convert numbers into a locale-specific currency representation (i.e., Euro, USD). The elementString (output variable) of each example is shown in the Task History, which is accessed from Jobs in Operations Manager.



    Examples: Euro

    toLocaleString-03

    toLocaleString-04



    Examples: USD

    toLocaleString-05

    toLocaleString-06

Further Reading

For more information on using the locales parameter, see the Intl page on the MDN site.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.