sqrt (JavaScript)

Gets the positive square root of a number.

Defined in

Math (JavaScript)

Syntax

abs(value:double) : double
Parameter Description
value A number. See below for special cases.
Return value Description
double The positive square root of the parameter.

Usage

Special cases are as follows:
  • The square root of NaN or a value less than 0 is NaN.
  • The square root of +Infinity is positive infinity.
  • The square root of +0 is positive zero.
  • The square root of -0 is negative zero.

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))