Baseline Widely available
format()
ã¡ã½ããã¯ããªã¹ãã®è¨èªåºæã®è¡¨ç¾ãæååã§è¿ãã¾ãã
const vehicles = ["Motorcycle", "Bus", "Car"];
const formatter = new Intl.ListFormat("en", {
style: "long",
type: "conjunction",
});
console.log(formatter.format(vehicles));
// Expected output: "Motorcycle, Bus, and Car"
const formatter2 = new Intl.ListFormat("de", {
style: "short",
type: "disjunction",
});
console.log(formatter2.format(vehicles));
// Expected output: "Motorcycle, Bus oder Car"
const formatter3 = new Intl.ListFormat("en", { style: "narrow", type: "unit" });
console.log(formatter3.format(vehicles));
// Expected output: "Motorcycle Bus Car"
æ§æ 弿°
list
Array ãªã©ã®å復å¯è½ãªãã¸ã§ã¯ãã§ãã
ãªã¹ãã®ãã¹ã¦ã®è¦ç´ ã表ç¾ãããè¨èªã«ä¾åããæåå表ç¾ã§ãã
解説format()
ã¡ã½ããã¯ã Intl.ListFormat
ãªãã¸ã§ã¯ãã§æä¾ããã弿°ã«åºã¥ãã¦æ¸å¼åãããæååãè¿ãã¾ãã locales
㨠options
弿°ã§ format()
ã®åä½ãã«ã¹ã¿ãã¤ãºããã¢ããªã±ã¼ã·ã§ã³ããªã¹ããæ¸å¼åããè¨èªã®æ
£ç¿ãæå®ãããã¨ãã§ãã¾ãã
以ä¸ã®ä¾ã§ã¯ãè±èªã使ç¨ãããªã¹ãã®ãã©ã¼ããã¿ã¼ã®ä½ãæ¹ãç´¹ä»ãã¾ãã
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
仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4