JavaScript absolute value | abs method example code

Use the abs method to get absolute value in JavaScript. JavaScript Math.abs() method is return the absolute value of a number. It takes a number as a parameter.

Syntax of abs method

Example of JavaScript absolute value

Basic Example


JavaScript absolute value

More Examples

Q: How to get the absolute value of a number in JavaScript / JS?

Answer: Use the Math.abs() function, It returns the absolute value. the abs() function is a static function of the Math object, it must be invoked through the placeholder object called Math.

Do comment if you have any doubts and suggestion on topic.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.