More Samples
Download Wijmo

The wijmo.format Method

Creating strings based on formatted data can be challenging in JavaScript. ES2016 addressed that limitation by introducing Template Strings.

Unfortunately, browser support is still limited for that solution, so Wijmo provides a format function that works everywhere. The format function takes a format string with placeholders that contain variable names and format specifiers, and a data object that supplies the variables.

For example:

wijmo.format('Welcome {name}! You have {miles:n0} miles in your account.', {
    name: 'Joe',
    miles: 2332123

Another example:

wijmo.format('{name}, thanks for being a customer since {date:D}.', {
    name: 'Joe',
    date: new Date()