Home > Web Front-end > JS Tutorial > body text

JavaScript Math.round() method_javascript tips

WBOY
Release: 2016-05-16 15:24:50
Original
1407 people have browsed it

Definition and usage of Math.round() method:

The Math.round() method will round the parameters.

Click to see more related Math object methods and properties.

Grammar structure:

Math.round(x)

Parameter list:

参数 描述
x 必需。必须是数值类型。

Example code:

Example 1:

Copy code The code is as follows:

console.log(Math.round(-2.1));

Output result: -2.

Example 2:

Copy code The code is as follows:

console.log(Math.round(-2.9));

Output result: -3.

Example 3:

Copy code The code is as follows:

console.log(Math.round(2.9));

Output result: 3.

The above content is the entire description of the JavaScript Math.round() method introduced by the editor. I hope you like it.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!