How to find the absolute value of x by javascript
This article mainly introduces javascript how to find the absolute value of x, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
In javascript, you can use the abs () method of the Math object to find the absolute value of x. The purpose of this method is to calculate the absolute value and return the absolute value of a number. The syntax "Math.abs (x)".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
In javascript, you can use the abs () method of the Math object to find the absolute value of x.
Math.abs () returns the absolute value of a number.
Syntax: Math.abs (x)
X: required parameter, must be a numeric value (Number type).
Return value: absolute of x, Number type; NaN if x is not a number, and 0 if x is null.
Example:
Console.log (Math.abs (7.25); console.log (Math.abs (- 7.25)); console.log (Math.abs (null)); console.log (Math.abs ("Hello")); console.log (Math.abs (2x3))
Output result:
Thank you for reading this article carefully. I hope the article "how to find the absolute value of x in javascript" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!