JavaScript数学SQRT2属性

下面是一个例子 数学SQRT2 所有物

null
  • 例子:

    <script>
    // Here value of Math.SQRT2 is printed.
    document.write(Math.SQRT2);
    </script>

    
    

  • 输出:
    1.4142135623730951

这个 数学SQRT2 是JavaScript中的一个属性,仅用于查找2的平方根的值,其值约为 1.4142 . 就是,

&Sqrt; 2. = 1.4142

语法:

Math.SQRT2;

返回值: 它只返回2的平方根值,其值约为1.4142。

下面的示例演示了JavaScript中的Math SQRT2属性。

  • 例子: 这里2的平方根的简单值显示为输出。
    Input : Math.SQRT2
    Output : 1.4142135623730951

    以上房产的更多代码如下: 项目1: 2的平方根值可以按如下所示的函数形式打印。

    <script>
    // function is being called.
    function get_Value_of_square_root()
    {
    return Math.SQRT2;
    }
    // function is calling for getting
    // value of square root of 2
    document.write(get_Value_of_square_root());
    </script>

    
    

    输出:

    1.4142135623730951

    项目2: 这里我们考虑数学。SQRT2是一个函数,但实际上它是一个属性,这就是为什么要将错误显示为输出。

    <script>
    // Here we consider Math.SQRT2 as a function
    // but in actual it is a property that is why error
    // as output is being shown.
    document.write(Math.SQRT2(12));
    </script>

    
    

    输出:

    Error: Math.SQRT2 is not a function

    方案3: 它的应用是求2的平方根的值,这是在这个属性的帮助下完成的。在数学方面,它需要很多。 例子:

    <script>
    // Value of Math.SQRT2 is printed.
    document.write(Math.SQRT2);
    </script>

    
    

    输出:

    1.4142135623730951

    支持的浏览器:

    • 谷歌Chrome 1及以上版本
    • Internet Explorer 3及以上版本
    • Firefox 1及以上版本
    • 歌剧3及以上
    • Safari 1及以上
  • © 版权声明
    THE END
    喜欢就支持一下吧
    点赞14 分享