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