| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString | [Back] [Original] |
Get to know MDN better
const array = [1, "a", new Date("21 Dec 1997 14:12:00 UTC")];
const localeString = array.toLocaleString("en", { timeZone: "UTC" });
console.log(localeString);
// : "1,a,12/21/1997, 2:12:00 PM",
// "en" UTC
toLocaleString()
toLocaleString(locales)
toLocaleString(locales, options)
Array.prototype.toLocaleString toLocaleString locales options ","
:
locales options toLocaleString() Intl.ListFormat
undefinednull "null" "undefined"
toLocaleString prices Number.prototype.toLocaleString()
const prices = ["7", 500, 8123, 12];
prices.toLocaleString("ja-JP", { style: "currency", currency: "JPY" });
// "7,500,8,123,12"
locales Intl.ListFormat
const nums = [8888, 9999];
console.log(nums.toLocaleString("zh")); // "8,888,9,999"
const formatter = new Intl.ListFormat("zh", {
type: "conjunction",
style: "narrow",
});
console.log(formatter.format(nums.map((x) => x.toLocaleString("zh"))));
// "8,8889,999"
toLocaleString() undefined
console.log([1, , 3].toLocaleString()); // '1,,3'
toLocaleString() this length length
const arrayLike = {
length: 3,
0: 1,
1: 2,
2: 3,
3: 4, // length 3 toLocaleString()
};
console.log(Array.prototype.toLocaleString.call(arrayLike));
// 1,2,3
| ECMAScript 2027 LanguageSpecification # sec-array.prototype.tolocalestring |
| ECMAScript 2027 Internationalization API Specification # sup-array.prototype.tolocalestring |
Arrayat()concat()copyWithin()entries()every()fill()filter()find()findIndex()findLast()findLastIndex()flat()flatMap()forEach()includes()indexOf()join()keys()lastIndexOf()map()pop()push()reduce()reduceRight()reverse()shift()slice()some()sort()splice()toLocaleString()toReversed()toSorted()toSpliced()toString()unshift()values()with()[Symbol.iterator]()Object/Function| Web Proxy Viewer | New URL | Original Page |