--- title: Object.prototype.toLocaleString() slug: Web/JavaScript/Reference/Global_Objects/Object/toLocaleString tags: - JavaScript - Method - Object - Prototype translation_of: Web/JavaScript/Reference/Global_Objects/Object/toLocaleString ---
toLocaleString() 方法返回一个该对象的字符串表示。此方法被用于派生对象为了特定语言环境的目的(locale-specific purposes)而重载使用。
obj.toLocaleString();
表示对象的字符串。
{{jsxref("Object")}} toLocaleString 返回调用 {{jsxref("Object.toString", "toString()")}} 的结果。
该函数提供给对象一个通用的toLocaleString 方法,即使不是全部都可以使用它。 见下面的列表。
toLocaleString 的对象| Specification | Status | Comment |
|---|---|---|
| {{SpecName('ES3')}} | {{Spec2('ES3')}} | 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')}} | |
| {{SpecName('ESDraft', '#sec-object.prototype.tolocalestring', 'Object.prototype.toLocaleString')}} | {{Spec2('ESDraft')}} |
{{Compat("javascript.builtins.Object.toLocaleString")}}