• Skip to main content
  • Skip to search
  • Skip to select language
HTML

Structure of content on the web

  • Web APIs

    Interfaces for building web applications

  • Learn
    • CSS

      Learn to style content using CSS

    • Overview

      A customized MDN experience

    • FAQ

      Frequently asked questions about MDN Plus

  • HTTP Observatory

    Scan a website for free

  • JavaScript
  • Array.prototype.toLocaleString()
      • Deutsch
      • Español
      • Français
      • 日本語
      • 한국어
      • Português (do Brasil)
      • Русский
      • 中文 (简体)

    In this article

    • Try it
    • Syntax
    • Description
    • Examples
    • Specifications
    • Browser compatibility
    • See also
    1. Array.from()
    2. Array[Symbol.species]
  • Instance methods
    1. Array.prototype.entries()
    2. Array.prototype.find()
    3. Array.prototype.flat()
    4. Array.prototype.indexOf()
    5. Array.prototype.map()
    6. Array.prototype.reduceRight()
    7. Array.prototype.some()
    8. Array.prototype.toReversed()
    9. Array.prototype.unshift()
    10. Array: length
    11. Function.prototype.bind()
    12. Function: displayName Non-standard
    13. Function.prototype.arguments Non-standard Deprecated
    14. Function.prototype.caller Non-standard Deprecated
  • Instance methods
    1. Object.prototype.__defineGetter__() Deprecated
    2. Object.prototype.__defineSetter__() Deprecated
    3. Object.prototype.__lookupGetter__() Deprecated
    4. Object.prototype.__lookupSetter__() Deprecated
    5. Object.prototype.toLocaleString()
    6. Object.prototype.__proto__ Deprecated
    7. Array instances returns a string representing the elements of the array. The elements are converted to strings using their toLocaleString methods and these strings are separated by a locale-specific string (such as a comma ",").

  • Try it

    const array1 = [1, "a", new Date("21 Dec 1997 14:12:00 UTC")];
    const localeString = array1.toLocaleString("en", { timeZone: "UTC" });
    
    console.log(localeString);
    / Expected output: "1,a,12/21/1997, 2:12:00 PM",
    / This assumes "en" locale and UTC timezone - your results may vary
    

    Syntax

    js
    toLocaleString()
    toLocaleString(locales)
    toLocaleString(locales, options)
    

    Parameters

    locales Optional

    A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the locales argument, see the parameter description on the Intl main page.

    options Optional

    An object with configuration properties. What you can pass here depends on what elements are being converted. For example, for numbers, see Number.prototype.toLocaleString().

    Return value

    A string representing the elements of the array.

    Description

    The Array.prototype.toLocaleString method traverses its content, calling the toLocaleString method of every element with the locales and options parameters provided, and concatenates them with an implementation-defined separator (such as a comma ","). Note that the method itself does not consume the two parameters — it only passes them to the toLocaleString() of each element. The choice of the separator string depends on the host's current locale, not the locales parameter.

    If an element is undefined, null, it is converted to an empty string instead of the string "null" or "undefined".

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

    The toLocaleString() method is Number.prototype.toLocaleString() method to display the currency for the strings and numbers in the prices array:

    js
    const prices = ["¥7", 500, 8123, 12];
    prices.toLocaleString("ja-JP", { style: "currency", currency: "JPY" });
    
    / "¥7,¥500,¥8,123,¥12"
    

    Using toLocaleString() on sparse arrays

    toLocaleString() treats empty slots the same as undefined and produces an extra separator:

    js
    console.log([1, , 3].toLocaleString()); / '1,,3'
    

    Calling toLocaleString() on non-array objects

    The toLocaleString() method reads the length property of this and then accesses each property whose key is a nonnegative integer less than length.

    js
    const arrayLike = {
      length: 3,
      0: 1,
      1: 2,
      2: 3,
      3: 4, / ignored by toLocaleString() since length is 3
    };
    console.log(Array.prototype.toLocaleString.call(arrayLike));
    / 1,2,3
    

    Specifications

    Specification
    ECMAScript® 2026 Internationalization API Specification
    # sup-array.prototype.tolocalestring

    Browser compatibility

    See also

    • Indexed collections guide
    • Array
    • Array.prototype.toString()
    • TypedArray.prototype.toLocaleString()
    • Intl
    • Intl.ListFormat
    • Object.prototype.toLocaleString()
    • Number.prototype.toLocaleString()
    • Temporal.PlainDate.prototype.toLocaleString()

    Help improve MDN

    Intl API provides language sensitive string comparison, number formatting, date and time formatting, and more.","name":"Intl"}},"browserCompat":["javascript.builtins.Array.toLocaleString"],"pageType":"javascript-instance-method"}}

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant