[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat [Back]  [Original]

Intl.ListFormat - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Intl.ListFormat

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2021 4.

Intl.ListFormat .

In this article

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"

Intl.ListFormat()

Intl.ListFormat .

Intl.ListFormat.supportedLocalesOf()

.

Intl.ListFormat.prototype , Intl.ListFormat .

Intl.ListFormat.prototype.constructor

. Intl.ListFormat , Intl.ListFormat .

Intl.ListFormat.prototype[@@toStringTag]

@@toStringTag "Intl.ListFormat" . Object.prototype.toString() .

Intl.ListFormat.prototype.format()

.

Intl.ListFormat.prototype.formatToParts()

.

Intl.ListFormat.prototype.resolvedOptions()

Intl.ListFormat .

format

.

js
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

formatToParts

.

js
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" } ];

Specification
ECMAScript 2027 Internationalization API Specification
# listformat-objects


Web Proxy Viewer  |  New URL  |  Original Page