| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat | [Back] [Original] |
Get to know MDN better
Intl.ListFormat
const vehicles = ["Motorcycle", "Bus", "Car"];
const formatter = new Intl.ListFormat("en", {
style: "long",
type: "conjunction",
});
console.log(formatter.format(vehicles));
// : "Motorcycle, Bus, and Car"
const formatter2 = new Intl.ListFormat("de", {
style: "short",
type: "disjunction",
});
console.log(formatter2.format(vehicles));
// : "Motorcycle, Bus oder Car"
const formatter3 = new Intl.ListFormat("en", { style: "narrow", type: "unit" });
console.log(formatter3.format(vehicles));
// : "Motorcycle Bus Car"
Intl.ListFormat() Intl.ListFormat
Intl.ListFormat.prototype Intl.ListFormat
Intl.ListFormat.prototype.constructorIntl.ListFormat Intl.ListFormat
Intl.ListFormat.prototype[Symbol.toStringTag][Symbol.toStringTag] "Intl.ListFormat" Object.prototype.toString()
Intl.ListFormat.prototype.format()Intl.ListFormat.prototype.formatToParts()Intl.ListFormat.prototype.resolvedOptions() Intl.ListFormat
const list = ["Motorcycle", "Bus", "Car"];
console.log(
new Intl.ListFormat("en-GB", { style: "long", type: "conjunction" }).format(
list,
),
);
// Motorcycle, Bus and Car
console.log(
new Intl.ListFormat("en-GB", { style: "short", type: "disjunction" }).format(
list,
),
);
// Motorcycle, Bus or Car
console.log(
new Intl.ListFormat("en-GB", { style: "narrow", type: "unit" }).format(list),
);
// Motorcycle Bus Car
const list = ["Motorcycle", "Bus", "Car"];
console.log(
new Intl.ListFormat("en-GB", {
style: "long",
type: "conjunction",
}).formatToParts(list),
);
// [ { "type": "element", "value": "Motorcycle" },
// { "type": "literal", "value": ", " },
// { "type": "element", "value": "Bus" },
// { "type": "literal", "value": ", and " },
// { "type": "element", "value": "Car" } ];
| ECMAScript 2027 Internationalization API Specification # listformat-objects |
| Web Proxy Viewer | New URL | Original Page |