概述
toLocaleString() 方法返回一个该对象的字符串表示。该方法主要用于被本地化相关对象覆盖。
语法
obj.toLocaleString();
描述
Object's toLocaleString 返回调用 toString() 方法的结果。
该函数提供了一个通用的 toLocaleString 方法,即使不大可能被用到。见下面列表:
覆盖了 toLocaleString() 方法的对象
Array:Array.prototype.toLocaleString()Number:Number.prototype.toLocaleString()Date:Date.prototype.toLocaleString()
规范
| 规范版本 | 规范状态 | 注解 |
|---|---|---|
| ECMAScript 3rd Edition. | Standard | Initial definition. |
| ECMAScript 5.1 (ECMA-262) Object.prototype.toLocaleString |
Standard | |
| ECMAScript 2015 (6th Edition, ECMA-262) Object.prototype.toLocaleString |
Standard |
浏览器兼容性
| 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) |