Converting numbers to strings

To convert a number to a string with a fixed number of decimal places, use toFixed.

Loading TypeScript...

The toPrecision function returns a string with the specified number of significant digits, and toExponential returns a string in exponential notation with the given decimal precision.

Loading TypeScript...

You can also use toString to produce a string representation of the number. The first argument of toString is the base to output in (default is base 10).

Loading TypeScript...

Was this page helpful?