Revision 494733 of Object.prototype.toLocaleString()

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Object/toLocaleString
  • Revision title: Object.prototype.toLocaleString()
  • Revision id: 494733
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment

Revision Content

{{JSRef("Global_Objects", "Object")}}

Summary

The toLocaleString() method returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes.

Syntax

obj.toLocaleString();

Description

Object's toLocaleString returns the result of calling {{jsxref("Object.toString", "toString()")}}.

This function is provided to give objects a generic toLocaleString method, even though not all may use it. See the list below.

Objects overriding toLocaleString

  • Array: {{jsxref("Array.prototype.toLocaleString()")}}
  • Number: {{jsxref("Number.prototype.toLocaleString()")}}
  • Date: {{jsxref("Date.prototype.toLocaleString()")}}

Specifications

Specification Status Comment
ECMAScript 3rd Edition. Standard Initial definition.
{{SpecName('ES5.1', '#sec-15.2.4.3', 'Object.prototype.toLocaleString')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-object.prototype.tolocalestring', 'Object.prototype.toLocaleString')}} {{Spec2('ES6')}}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}

See also

  • {{jsxref("Object.prototype.toString()")}}

Revision Source

<div>
 {{JSRef("Global_Objects", "Object")}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code><strong>toLocaleString()</strong></code> method returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<code><var>obj</var>.toLocaleString();</code></pre>
<h2 id="Description" name="Description">Description</h2>
<p><code>Object</code>'s <code>toLocaleString</code> returns the result of calling {{jsxref("Object.toString", "toString()")}}.</p>
<p>This function is provided to give objects a generic <code>toLocaleString</code> method, even though not all may use it. See the list below.</p>
<h3 id="Objects_overriding_toLocaleString">Objects overriding toLocaleString</h3>
<ul>
 <li><code>Array</code>: {{jsxref("Array.prototype.toLocaleString()")}}</li>
 <li><code>Number</code>: {{jsxref("Number.prototype.toLocaleString()")}}</li>
 <li><code>Date</code>: {{jsxref("Date.prototype.toLocaleString()")}}</li>
</ul>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>ECMAScript 3rd Edition.</td>
   <td>Standard</td>
   <td>Initial definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.2.4.3', 'Object.prototype.toLocaleString')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-object.prototype.tolocalestring', 'Object.prototype.toLocaleString')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Chrome for Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Mobile</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
 <li>{{jsxref("Object.prototype.toString()")}}</li>
</ul>
Revert to this revision