Format Function

The Format function provides a much richer string formatting mechanism than standard JavaScript. The first parameter is a string that contains format specifiers surrounded with curly braces. Escape braces by doubling them, for example "{{" becomes "{" in the output. Format specifiers start at zero and increase incrementally. If you omit a specifier from a sequence, the equivalent parameter to the Format function is ignored. For example, "{1}" ignores the first value parameter to Format and uses the second.

There is one shortcut. You can call Format and pass a format specifier without braces and pass only one argument. The result is equivalent to Format("{0:<specifier>", <argument>)

The format specifiers work similarly to other languages like Java or C#. The syntax is {<paramnum>} or {<paramnum>;<format>}, where paramnum is a positive whole integer starting at zero and increasing sequentially. The format param depends on the type of the object passed in as that parameter.

The format parameters generally return values appropriate to the user's locale; for example, in the US "{0:0.00}" returns "1.23" while in Europe it returns "1,23"). Alternately, you can use the escaping support to explicitly override the locale and output the same value for all users. For example, "#\,###\,##0" would format a number using commas as thousands separators in all regions, regardless of culture settings.