Easy Tutorial
❮ Prop Style Clear Jsref Regexp Begin Not ❯

JavaScript abs() Method

JavaScript Math Object

Example

Example

Return the absolute value of a number:

Output result:


Definition and Usage

The abs() method returns the absolute value of a number.


Browser Support

All major browsers support the abs() method.


Syntax

Parameter Values

Parameter Description
x Required. Must be a numeric value.

Return Value

Type Description
Number The absolute value of x. Returns NaN if x is not a number, or 0 if x is null.

Technical Details

| JavaScript Version: | 1.0 | | --- | --- |


More Examples

Example

In this example, I will get the absolute values of different types of arrays:

Output result:


JavaScript Math Object

❮ Prop Style Clear Jsref Regexp Begin Not ❯