<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<script>
const list = ['un', 'deux', 'trois'];
const formatter = new Intl.ListFormat('fr', {
style: 'long',
type: 'conjunction'
});
// format : un, deux et trois
console.log(formatter.format(list));
const formatterNarrow = new Intl.ListFormat('fr', {
style: 'narrow',
type: 'unit'
});
// format : un deux trois
console.log(formatterNarrow.format(list));
</script>
<body>
</body>
</html>
Commentaires
Enregistrer un commentaire