JavaScript Internals (521 Qs)•Part 4: Prototypes, Object Methods & Event Loop (174 - 253)
What are the properties of the Intl object
Below are the list of properties available on the Intl object,
- Collator: These are the objects that enable language-sensitive string comparison.
- DateTimeFormat: These are the objects that enable language-sensitive date and time formatting.
- ListFormat: These are the objects that enable language-sensitive list formatting.
- NumberFormat: Objects that enable language-sensitive number formatting.
- PluralRules: Objects that enable plural-sensitive formatting and language-specific rules for plurals.
- RelativeTimeFormat: Objects that enable language-sensitive relative time formatting.
Practical Code Example
javascript
// Key Constructors on the Intl Namespace:
console.log(typeof Intl.Collator); // String comparison for sorting
console.log(typeof Intl.DateTimeFormat); // Date/Time formatting
console.log(typeof Intl.NumberFormat); // Currency and percent formatting
console.log(typeof Intl.PluralRules); // Language-specific plural rules
console.log(typeof Intl.RelativeTimeFormat); // e.g., '3 days ago'