How to get whole number or with specified decimal points from decimal type using JavaScript?

Sample Code:

var numberObject = 123.4567;
document.write( numberObject.toFixed() ); // 123
document.write( numberObject.toFixed( 1 ) ); // 123.5
document.write( numberObject.toFixed( 2 ) ); // 123. 46
document.write( numberObject.toFixed( 3 ) ); // 123. 457

No comments:

Post a Comment