这个方法返回一个数的平方根。如果数的值是负的,开方返回nan。
语法
math.sqrt( x ) ;
下面是参数的详细信息:
返回值:
例子:
<html> <head> <title>javascript math sqrt() method</title> </head> <body> <script type="text/javascript"> var value = math.sqrt( 0.5 ); document.write("first test value : " + value ); var value = math.sqrt( 81 ); document.write("<br />second test value : " + value ); var value = math.sqrt( 13 ); document.write("<br />third test value : " + value ); var value = math.sqrt( -4 ); document.write("<br />fourth test value : " + value ); </script> </body> </html>
这将产生以下结果:
first test value : 0.7071067811865476 second test value : 9 third test value : 3.605551275463989 fourth test value : nan
如对本文有疑问, 点击进行留言回复!!
vue源码实战render.js与$nextTick的异步调用
同事牛逼啊,写了个隐藏 bug,我排查了 3 天才解决问题!
【JavaScript笔记(一)】万丈高楼平地起 - 基本概念篇
网友评论