-
-
Save icesernia/47f1a6a88cc83f24e21b67408620dcfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const vehicles = ['Motorcycle', 'Bus', 'Car']; | |
const formatter_en = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' }); | |
const formatter_en_short = new Intl.ListFormat('en', { style: 'short', type: 'conjunction' }); | |
const formatter_en_narrow = new Intl.ListFormat('en', { style: 'narrow' }); | |
const formatter_th = new Intl.ListFormat('th', { style: 'long', type: 'disjunction' }); | |
console.log(formatter_en.format(vehicles)); // expected output: Motorcycle, Bus, and Car | |
console.log(formatter_en_short.format(vehicles)); // expected output: Motorcycle, Bus, & Car | |
console.log(formatter_en_narrow.format(vehicles)); // expected output: Motorcycle, Bus, Car | |
console.log(formatter_th.format(vehicles)); // expected output: Motorcycle Bus หรือCar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment