Home >Web Front-end >JS Tutorial >ToFixed in javascript fixes the number of decimal places. Simple example sharing_javascript skills

ToFixed in javascript fixes the number of decimal places. Simple example sharing_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:28:581056browse

[code]
<script> <br>var a=4.2343; <br>alert(a.toFixed(3)); <br></script>
<script><br>var a=4.2343;<br>alert(a.toFixed(3));<br></script>
Execution result:

ToFixed in javascript fixes the number of decimal places. Simple example sharing_javascript skills

The toFixed method converts a number into a string with a fixed number of decimal places.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn