math.sqrt 有问题

JavaScript | Math.sqrt()方法 (JavaScript | Math.sqrt() Method)

The Math.sqrt() method is inbuilt in JavaScript to find the square root of a number. In this tutorial, we will learn about the sqrt() method with examples.

JavaScript中内置了Math.sqrt()方法 ,以查找数字的平方根 。 在本教程中,我们将通过示例了解sqrt()方法

In the math library inbuilt in the JavaScript programming language. There are many methods that support mathematical operations. The sqrt() method in JavaScript is used to find the square root of the number that is passed to the method as parameters.

在JavaScript编程语言内置的数学库中。 有许多支持数学运算的方法。 JavaScript中sqrt()方法用于查找作为参数传递给该方法的数字的平方根。

Syntax:

句法:

    Math.sqrt(n);

Parameter(s):

参数:

  • n – It takes only one value which is an integer whose square root is to be found.

    n –仅取一个值,该值是要找到其平方根的整数。

Return value:

返回值:

The return type of this method is number, it returns the square root of the given parameter, if the given number is negative then it returns NaN.

此方法的返回类型为number ,它返回给定参数的平方根,如果给定数字为负,则返回NaN 。

Example 1: passing integers to the sqrt() method.

示例1:将整数传递给sqrt()方法。

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script>
document.write(Math.sqrt(4) + "<br>");
document.write(Math.sqrt(12.56));
</script>
</body>
</html>

Output

输出量

Passing other values to the sqrt() method

将其他值传递给sqrt()方法

All the following values if passed to the sqrt() method will return NaN. Denoting not a number passed to the method: Negative numeric value, non-numeric strings, an array with multiple numeric values, empty string or array.

如果将以下所有值传递给sqrt()方法,则将返回NaN 。 不表示传递给该方法的数字:负数值,非数字字符串,具有多个数值的数组,空字符串或数组。

Example 2: passing error values to method that will return NaN.

示例2:将错误值传递给将返回NaN的方法。

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script>
document.write(Math.sqrt(-6) + "<br>");
document.write(Math.sqrt("Include Help") + "<br>");
</script>
</body>
</html>

Output

输出量

You can also to operations inside the method and the result of these operations will be passed to the method to calculate the square root.

您也可以在方法内部进行运算,并将这些运算的结果传递给方法以计算平方根。

Example 3: passing expressions to sqrt() method.

示例3:将表达式传递给sqrt()方法。

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script>
document.write(Math.sqrt(5.3 + 3.7) + "<br>");
</script>
</body>
</html>

Output

输出量

翻译自: https://www.includehelp.com/code-snippets/math-sqrt-method-with-example-in-javascript.aspx

math.sqrt 有问题

math.sqrt 有问题_JavaScript中带有示例的Math.sqrt()方法相关推荐

  1. math.sqrt 有问题_JavaScript中带有示例的Math.SQRT2属性

    math.sqrt 有问题 JavaScript | Math.SQRT2属性 (JavaScript | Math.SQRT2 Property) Math.SQRT2 is a property ...

  2. math.ceil带小数点_JavaScript中带有示例的Math.ceil()方法

    math.ceil带小数点 JavaScript | Math.ceil()方法 (JavaScript | Math.ceil() Method) Math.ceil() is a function ...

  3. arm中clz指令_JavaScript中带有示例的Math.clz32()方法

    arm中clz指令 JavaScript | Math.clz32()方法 (JavaScript | Math.clz32() Method) Math.clz32() is a function ...

  4. np.cosh没有分配_JavaScript中带有示例的Math.cosh()方法

    np.cosh没有分配 JavaScript | Math.cosh()方法 (JavaScript | Math.cosh() Method) Math operations in JavaScri ...

  5. asinh函数_JavaScript中带有示例的Math.asinh()方法

    asinh函数 JavaScript | Math.asinh()方法 (JavaScript | Math.asinh() Method) Math.asinh() is a function in ...

  6. math.ceil带小数点_Python中带有示例的math.ceil()方法

    math.ceil带小数点 Python math.ceil()方法 (Python math.ceil() method) math.ceil() method is a library metho ...

  7. JavaScript中带有示例的Math.log10()方法

    JavaScript | Math.log10()方法 (JavaScript | Math.log10() Method) Math operations in JavaScript are han ...

  8. JavaScript中带有示例的Math.abs()方法

    JavaScript | Math.abs()方法 (JavaScript | Math.abs() Method) Math operations in JavaScript are handled ...

  9. JavaScript中带有示例的Math.max()方法

    JavaScript | Math.max()方法 (JavaScript | Math.max() Method) Math.max() is a function in math library ...

最新文章

  1. 9.如何使用QT绘制导航箭头的图标
  2. python语言入门n-python语言入门之字符串的一些用法
  3. UA MATH564 概率分布1 二项分布下
  4. 【小技巧】Xcode7.1中KSImageNamed无效的解决方法
  5. 声学漫谈之六:音腔频段如何判定?
  6. Boost::context模块callcc的jump mov测试程序
  7. 每天一道LeetCode-----将数值数组按一定顺序拼接,使得拼接的结果最大
  8. Vtk读取并显示保存图像
  9. SI4463模块配合WDS的快速上手指南
  10. 人物角色群体攻击判定二(叉乘来判断敌人的位置)
  11. heatmap个人简单理解
  12. 【POJ1083】 Moving Tables (并行的搬运)
  13. 计算机课组会议讲话,备课组长会议讲话稿
  14. gitlab和jenkins发布代码
  15. c++:warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  16. Java中Word转PDF解决方案
  17. Hidden Markov Models Forward算法
  18. Flask PyMongo的基本使用
  19. 8421拨码开关C语言编程,8052单片机怎样读出8421BCD码拨码开关设定的数值
  20. 《前端单位和网络地址》随手学习笔记

热门文章

  1. 实战|全程分析js到getshell
  2. android view getwidth 0,Android中View.getWidth()和View.getMeasuredWidth()的区别
  3. Raect Router 4 的使用 (1)
  4. jsp输出所有请求头的名称
  5. html css3模拟心的跳动
  6. css3 flex 布局
  7. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: jav
  8. NodeJS常用模块介绍
  9. [KISSY5系列]淘宝全终端框架 KISSY 5--从零开始使用
  10. SQL Server 2005 DTS导入平面数据