Standard built-ins

Math.sqrt()

Try the free JavaScript compiler

Nonnegative square root of a nonnegative Number; negative inputs except -0 produce NaN, and -0 stays -0. Converts x to Number; BigInt conversion throws TypeError.

Formal Syntax & Structure

javascript syntaxjavascript
Math.sqrt(x)

Parameters & Attributes

NameTypeDescription
xnumberNumber input or value coercible to Number.

Return Value

number

Result of the numerical operation, possibly NaN.

Working Example

Example Snippetjavascript
console.log(Math.sqrt(49),Number.isNaN(Math.sqrt(-1)));
JavaScript Reference