JavaScript Objects The Number Object- toPrecision() - Javascript Objects

What is JavaScript Number - toPrecision()?

toPrecision() method - returns a string that represents the number object to the specified precision.

Syntax:

Its syntax is as follows −

Parameter Details:

precision − An integer specifying the number of significant digits.

Return Value:

Returns a string that represents a Number object in fixed-point or exponential notation rounded toprecision significant digits.

Example:

Observe the following example -

Output:

JavaScript Number Object toPrecision()


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Javascript Objects Topics