Get the App
SLTechnology News&Howtos  ›  Development  › 

Operation Analysis of round,pow,sqrt,abs instance of JavaScript Math function

Shulou Source: shulou.com Published: 2022-06-01 04:58:05 10月04日 Update

This article mainly introduces "round,pow,sqrt,abs instance operation analysis of JavaScript Math function". In daily operation, I believe that many people have doubts about the operation analysis of round,pow,sqrt,abs instance of JavaScript Math function. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "round,pow,sqrt,abs instance operation analysis of JavaScript Math function". Next, please follow the editor to study!

The JavaScript Math object allows you to perform mathematical tasks on numbers.

Example

Math.PI; / / returns 3.141592653589793

Math.round ()

The return value of Math.round (x) is x rounded to the nearest integer:

Example

Math.round (6.8); / / returns 7

Math.round (2.3); / / return 2

Math.pow ()

The return value of Math.pow (x, y) is the y power of x:

Example

Math.pow (8, 2); / / return 64

Math.sqrt ()

Math.sqrt (x) returns the square root of x:

Example

Math.sqrt (64); / / returns 8

Math.abs ()

Math.abs (x) returns the absolute (positive) value of x:

Example

Math.abs (- 4.7); / / returns 4.7

At this point, the study of "round,pow,sqrt,abs instance operation analysis of JavaScript Math function" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Examples functions analysis learning more help practical rounded next tasks objects square roots numbers mathematics integers articles methods theory knowledge articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Linux OPPO Reno MySQL Redmi