abs (JavaScript)

Gets the absolute value of a number.

Defined in

Math (JavaScript)

Syntax

abs(value:double) : double
Parameter Description
value A number.
Return value Description
double The parameter if it is positive. The negation of the parameter if it is negative.

Examples

This edit box onblur event gets the absolute value of a number before calculating its square root.
sessionScope.n = Math.sqrt(Math.abs(sessionScope.n))