var num = 1; var result = num.toFixed(2); // result = 1.00 num = 123.4567; result = num.toFixed(3); // result = 123.456 num = 123.4567; result = num.toPrecision(4); // result = 123.4 num = 123.4567; result = num.toPrecision(3); // result = 123 num = 555.55; result = num.toPrecision(2); // result will equal 5.6e+2
see also this article.
No comments:
Post a Comment