YUI 3.x Home -

YUI Library Examples: DataType Utility: DataType.Number.format()

Note: This is YUI 3.x. Looking for YUI 2.x?

DataType Utility: DataType.Number.format()

The Number module of the DataType Utility allows you to take a number and format it into a string with the following configuration parameters: decimalPlaces, decimalSeparator, thousandsSeparator, prefix, and suffix.

:

To output a number as a string, simply call the format() function of the DataType.Number class:

The format() function also takes a variety of configuration parameters that manipulate the value of the string. This is helpful, for instance, when displaying numbers as currency:

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings