Javascript Math.abs() is an inbuilt function that returns the absolute value of a number. It takes a number as its parameter and returns its absolute value. Parameters: The number whose absolute value is to be found is passed as the parameter to the math.abs() function.

Javascript abs() Function

To find the absolute value of a given argument in JavaScript, Math.abs() method is used. This method is often helpful when the program deals with mathematical expressions where the |x| value (the absolute value of a variable x) is required to be calculated. Since abs() is a static method of Math, it can be used without creating an  object.

Syntax

Math.abs(x)

#javascript #js

Javascript abs() Function | Math.abs() in Javascript Example
3.45 GEEK