JavaScript Tutorial/Math/SQRT1 2

Материал из Web эксперт
Перейти к: навигация, поиск

Math.SQRT1_2

The SQRT1_2 property returns the square root of one half, which is approximately 0.707.



<html>
    <body>
    <script language="JavaScript">
    <!--
    function doMath(){
        var result = Math.SQRT1_2;
        document.form1.answer.value = result;
    }
    -->
    </script>
    <form name=form1>
    The square root of 1/2 is:
    <input type="text" name="answer" size=20>
    <input type="button" value="Calculate" onClick="doMath()">
    <br>
    </form>
    </body>
    </html>


The value of the square root of 1/2: Math.SQRT1_2

<html>
<head>
<title>The Properties of the Math object</title>
<script type="text/javascript" language="javascript">
<!-- //
function DisplayMath(){
    document.write("<br/><P>The value of the square root of 1/2 is: " + Math.SQRT1_2 + "</p>");
}
// -->
</script>
</head>
<body onload="DisplayMath()">
</body>
</html>