aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/javascript/reference/global_objects/array/tolocalestring/index.html
blob: a4d9bd5ee9dc5a97768cb30d55c5278b724667e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: Array.prototype.toLocaleString()
slug: Web/JavaScript/Reference/Global_Objects/Array/toLocaleString
tags:
  - Array
  - Internationalization
  - JavaScript
  - Method
  - Prototype
translation_of: Web/JavaScript/Reference/Global_Objects/Array/toLocaleString
---
<div>{{JSRef("Global_Objects", "Array")}}</div>

<h2 id="Summary">Сводка</h2>

<p>Метод <code><strong>toLocaleString()</strong></code> возвращает строковое представление элементов массива. Элементы преобразуются в строки с использованием своих собственных методов <code>toLocaleString</code> и эти строки разделяются локале-зависимой строкой (например, запятой «,»).</p>

<h2 id="Syntax">Синтаксис</h2>

<pre class="syntaxbox"><code><var>arr</var>.toLocaleString();</code></pre>

<h3 id="Parameters">Параметры</h3>

<p>Нет.</p>

<h2 id="Description">Описание</h2>

<p>Элементы массива преобразуются в строки с использованием своих собственных методов <code>toLocaleString</code>:</p>

<ul>
 <li><code>Object</code>: {{jsxref("Object.prototype.toLocaleString()")}}</li>
 <li><code>Number</code>: {{jsxref("Number.prototype.toLocaleString()")}}</li>
 <li><code>Date</code>: {{jsxref("Date.prototype.toLocaleString()")}}</li>
</ul>

<h2 id="Examples">Примеры</h2>

<h3 id="Example:_Using_toLocaleString">Пример: использование <code>toLocaleString</code></h3>

<pre class="brush: js">var number = 1337;
var date = new Date();
var myArr = [number, date, 'foo'];

var str = myArr.toLocaleString();

console.log(str);
// напечатает '1337,6.12.2013 19:37:35,foo',
// если работает под германской локалью (de-DE) с временной зоной Европа/Берлин
</pre>

<h2 id="Specifications">Спецификации</h2>

{{Specifications}}

<h2 id="Browser_compatibility">Совместимость с браузерами</h2>

<p>{{Compat}}</p>

<h2 id="See_also">Смотрите также</h2>

<ul>
 <li>{{jsxref("Array.prototype.toString()")}}</li>
</ul>