toLocaleString()
method returns a string representing the elements of the typed array. The elements are converted to strings and are separated by a locale-specific string (such as a comma “,”). This method has the same algorithm as
Array.prototype.toLocaleString()
and, as the typed array elements are numbers, the same algorithm as
Number.prototype.toLocaleString()
applies for each element.
TypedArray
is one of the
typed array types
here.
typedarray.toLocaleString([locales [, options]]);
locales
and
options
arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. In implementations, which ignore the
locales
and
options
arguments, the locale used and the form of the string returned are entirely implementation dependent.
Intl.NumberFormat()
构造函数
for details on these parameters and how to use them.
A string representing the elements of the typed array.
toLocaleString
var uint = new Uint32Array([2000, 500, 8123, 12, 4212]);
uint.toLocaleString();
// if run in a de-DE locale
// "2.000,500,8.123,12,4.212"
uint.toLocaleString('en-US');
// "2,000,500,8,123,12,4,212"
uint.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' });
// "¥2,000,¥500,¥8,123,¥12,¥4,212"
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'TypedArray.prototype.toLocaleString' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toLocaleString
|
Chrome 7 | Edge 12 | Firefox 51 | IE 10 | Opera 11.6 | Safari 5.1 | WebView Android ≤37 | Chrome Android 18 | Firefox Android 51 | Opera Android 12 | Safari iOS 5 | Samsung Internet Android 1.0 | nodejs 0.10 |
完整支持
TypedArray
TypedArray.from()
TypedArray.of()
TypedArray.prototype.copyWithin()
TypedArray.prototype.entries()
TypedArray.prototype.every()
TypedArray.prototype.fill()
TypedArray.prototype.filter()
TypedArray.prototype.find()
TypedArray.prototype.findIndex()
TypedArray.prototype.forEach()
TypedArray.prototype.includes()
TypedArray.prototype.indexOf()
TypedArray.prototype.join()
TypedArray.prototype.keys()
TypedArray.prototype.lastIndexOf()
TypedArray.prototype.map()
TypedArray.prototype.reduce()
TypedArray.prototype.reduceRight()
TypedArray.prototype.reverse()
TypedArray.prototype.set()
TypedArray.prototype.slice()
TypedArray.prototype.some()
TypedArray.prototype.sort()
TypedArray.prototype.subarray()
TypedArray.prototype.toLocaleString()
TypedArray.prototype.toString()
TypedArray.prototype.values()
TypedArray.prototype[@@iterator]()
Int8Array
Uint8Array
Uint8ClampedArray
Int16Array
Uint16Array
Int32Array
Uint32Array
Float32Array
Float64Array
BigInt64Array
BigUint64Array
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()