10.07.2017 Views

javascript_tutorial

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Javascript<br />

var num = new Number(177.1234);<br />

document.write( num.toLocaleString());<br />

<br />

<br />

<br />

Output<br />

177.123<br />

toPrecision ()<br />

This method returns a string representing the number object to the specified<br />

precision.<br />

Syntax<br />

Its syntax is as follows:<br />

number.toPrecision( [ precision ] )<br />

Parameter Details<br />

precision: An integer specifying the number of significant digits.<br />

Return Value<br />

Returns a string representing a Number object in fixed-point or exponential<br />

notation rounded toprecision significant digits.<br />

Example<br />

Try the following example.<br />

<br />

<br />

JavaScript toPrecision() Method <br />

<br />

<br />

<br />

var num = new Number(7.123456);<br />

125

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!