JavaScript Getting Absolute Value

In JavaScript, the Math.abs() function is used for the absolute value operation.

The absolute value of a real number means the distance of the point on the number axis from the starting point (0). |x| is displayed with . Accordingly, for example, since the distance of 5 and -5 from the 0 origin is 5 units, the absolute value of both will be 5.

Usage is given in the examples below..

The results are below..



You May Interest

What is Event Capturing in Javascript ?

JavaScript Concatenating Arrays

What is Console Object in Javascript ?

What is Difference Between Undefined and Null in Javascript ?

Javascript Removing Elements from Array