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 are the Variable Naming Conventions in JavaScript ?

What are Advantages of Using External Javascript ?

What are Different Javascript Frameworks ?

What are Deferred Scripts in Javascript ?

What is Prototype in Javascript ?