JavaScript Tutorial

Español Français 中文 Deutsch Portuguese Japanese nederlands
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback

Math.abs() Function

Tutorials Javascript


What is the use of Math.abs() method in Javascript?
How to get the absolute value of an number in javascript?


Object: Math

Method: Math.abs()

Description:This function is used to get the absolute value of a number.

<script type="text/javascript">
document.write('Absolute value of -4.23 is ::'+Math.abs(-4.23) + "<br/>");
document.write('Absolute value of null is ::'+Math.abs(null) + "<br/>");

In the above example,
  • Absolute value of negative number gives a positive value whereas for a null value it is "0".

  • A Note
    Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

    Other Links

    web hosting