Metoda
toLocaleString()
zwraca łańcuch znaków reprezentujący wszystkie elementy w tablicy. Każdy element jest konwerterowany do łańcucha znaku za pomocą lokalnych wywołań toLocaleString. Elementy
łaczone są separatorem zdefiniowanym dla lokalnego języka (np. przecinek).Składnia
arr.toLocaleString();
Opis
Poniższe elementy tablic są konwertowane na łańcuchy znaków za pomocą wbudowanych metod toLocaleString
Przykład
Użycie toLocaleString
let numer = 1337; let data = new Date(); let tablica = [numer , data, 'foo']; let str = tablica.toLocaleString(); console.log(str); // logs '1337,19.11.2020, 17:21:06,foo' // if run in a Polish (pl-PL) locale with timezone Europe/Warsaw let strEn = tablica.toLocaleString("en-US"); // "1,337,11/19/2020, 5:21:06 PM,foo"
Specyfikacja
Specyfikacja | Status | Komentarze |
---|---|---|
ECMAScript 3rd Edition (ECMA-262) | Standard | Inicjalna definicja |
ECMAScript 5.1 (ECMA-262) The definition of 'Array.prototype.toLocaleString' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Array.prototype.toLocaleString' in that specification. |
Standard |
Zgodność z przeglądarkami
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |