javascript
math.sqrt 有问题_JavaScript中带有示例的Math.sqrt()方法
math.sqrt 有問(wèn)題
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中內(nèi)置了Math.sqrt()方法 ,以查找數(shù)字的平方根 。 在本教程中,我們將通過(guò)示例了解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編程語(yǔ)言內(nèi)置的數(shù)學(xué)庫(kù)中。 有許多支持?jǐn)?shù)學(xué)運(yùn)算的方法。 JavaScript中的sqrt()方法用于查找作為參數(shù)傳遞給該方法的數(shù)字的平方根。
Syntax:
句法:
Math.sqrt(n);Parameter(s):
參數(shù):
n – It takes only one value which is an integer whose square root is to be found.
n –僅取一個(gè)值,該值是要找到其平方根的整數(shù)。
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 ,它返回給定參數(shù)的平方根,如果給定數(shù)字為負(fù),則返回NaN 。
Example 1: passing integers to the sqrt() method.
示例1:將整數(shù)傳遞給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 。 不表示傳遞給該方法的數(shù)字:負(fù)數(shù)值,非數(shù)字字符串,具有多個(gè)數(shù)值的數(shù)組,空字符串或數(shù)組。
Example 2: passing error values to method that will return NaN.
示例2:將錯(cuò)誤值傳遞給將返回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.
您也可以在方法內(nèi)部進(jìn)行運(yùn)算,并將這些運(yùn)算的結(jié)果傳遞給方法以計(jì)算平方根。
Example 3: passing expressions to sqrt() method.
示例3:將表達(dá)式傳遞給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 有問(wèn)題
總結(jié)
以上是生活随笔為你收集整理的math.sqrt 有问题_JavaScript中带有示例的Math.sqrt()方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 妊娠纹修复多少钱啊?
- 下一篇: math.ceil带小数点_JavaSc