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 For Loop

What are Different Javascript Frameworks ?

JavaScript Adding Elements to Array

What are the Variable Naming Conventions in JavaScript ?

What is Difference Between Javascript and ECMAScript ?