ES6 - Math.hypot(x1, x2,...) 函式



返回引數之和的平方根。

語法

Math.hypot( x1,x2.. ) ;   

引數

  • X1 和 x2.. − 表示數字

返回值

返回所有作為引數傳遞的數字之和的平方根

示例

console.log("---Math.hypot()---") 
console.log("Math.hypot(3,4) : "+Math.hypot(3,4)) 
console.log("Math.hypot(2,3,4) : "+Math.hypot(2,3,4))        

輸出

---Math.hypot()--- 
Math.hypot(3,4) : 5 
Math.hypot(2,3,4) : 5.385164807134504           
廣告