Get to know MDN better
此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。
Math.sqrt() 函数返回一个数的平方根,即:
∀x≥0,Math.sqrt(x)=x=the uniquey≥0such thaty2=x\forall x \geq 0, \mathtt{Math.sqrt(x)} = \sqrt{x} = \text{the unique} ; y \geq 0 ; \text{such that} ; y^2 = x一个数值
如果参数 number 为负值,则 sqrt 返回NaN。
由于 sqrt 是 Math 的静态方法,所以应该像这样使用:Math.sqrt(),而不是作为你创建的 Math 实例的方法。
| ECMAScript® 2027 Language Specification # sec-math.sqrt |
启用 JavaScript 以查看此浏览器兼容性表。