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

JavaScript Using While Loop

What are Different Javascript Frameworks ?

JavaScript Concatenating Arrays

What is Difference Between Undefined and Null in Javascript ?

How to Handle Exceptions in JavaScript ?