Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Array.prototype.toLocaleString()

概述

toLocaleString() 返回一个字符串表示数组中的元素。数组中的元素将使用各自的 toLocaleString 方法转成字符串,这些字符串将使用一个特定语言环境的字符串(例如一个逗号 ",")隔开。

语法

arr.toLocaleString();

描述

数组中的元素将会使用各自的 toLocaleString 方法:

示例

例子:使用 toLocaleString

var number = 1337;
var date = new Date();
var myArr = [number, date, "foo"];

var str = myArr.toLocaleString(); 

console.log(str); 
// 输出 "1337,2015/2/27 下午8:29:04,foo" 
// 假定运行在中文(zh-CN)环境,北京时区

规范

Specification Status Comment
ECMAScript 3rd Edition. Standard Initial definition.
ECMAScript 5.1 (ECMA-262)
Array.prototype.toLocaleString
Standard  
ECMAScript 6 (ECMA-262)
Array.prototype.toLocaleString
Release Candidate  

浏览器兼容性

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)

相关链接

文档标签和贡献者

 此页面的贡献者: AlexChao
 最后编辑者: AlexChao,