Math.SQRT2
JavaScript 1.0+, ECMAScript 1E+, JScript 1.0+
Nav2+, NES2+, IE3+, Opera3+
Syntax
math.SQRT2
Description
The SQRT2
property of the Math
object returns the value of the square root of 2. This is approximately equal to 1.414.
Example
Listing 7.256 shows how the SQRT2
property is used. The function, doMath
, returns the square root of 2 to the text box on the page.
<html><body><script type=“text/javascript” language=“JavaScript”><!--// Function returns the square root of 2.function doMath(){ var result = Math.SQRT2; document.form1.answer.value = result;}// --></script><form name=“form1”>The square root of 2 is:<input type=“text” name=“answer” size=“20”><input type=“button” value=“Calculate” onClick='doMath()'> ...
Get Pure JavaScript, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.