Demo showing the use of the format method

The format method is used by both NumberFormat and DateTimeFormat to format based on the supplied or default options.

by David Storey

JavaScript

var locale = "en-GB",
    localeNumber = new Intl.NumberFormat(locale),
    localeDate = new Intl.DateTimeFormat(locale);

console.log(localeNumber.format(1000.15)); // 1,000.15 with default formatting
console.log(localeDate.format(new Date())) // 23/8/2013  with default formatting