A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format below:

Intl.ListFormat.prototype.format() - JavaScript | MDN

Intl.ListFormat.prototype.format()

Baseline Widely available

La méthode format() renvoie une chaîne de caractères représentant la liste passée en argument, mise en forme selon la langue choisie (lors de la construction de l'objet Intl.ListFormat).

Exemple interactif
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"
Description

La méthode format() renvoie une chaîne de caractères qui a été formatée en fonction des paramètres fournis à l'objet Intl.ListFormat. Les paramètres locales et options permettent de personnaliser le comportement de format() et de gérer différentes conventions linguistiques au sein d'une application, notamment pour la mise en forme des listes.

Syntaxe
listFormat.format([list]);
Paramètres
list

Un objet itérable (ex. un tableau / Array).

Valeur de retour

Une chaîne de caractères représentant les éléments de la liste et mise en forme en fonction de la langue souhaitée (grâce au paramètre locales passé au constructeur Intl.ListFormat).

Spécifications Compatibilité des navigateurs Voir aussi

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