JavaScript中带有示例的Math.abs()方法
JavaScript | Math.abs()方法 (JavaScript | Math.abs() Method)
Math operations in JavaScript are handled using functions of math library in JavaScript. In this tutorial on Math.abs() method, we will learn about the abs() method and its working with examples.
JavaScript中的数学运算是使用JavaScript中的数学库函数处理的。 在有关Math.abs()方法的教程中,我们将学习abs()方法及其示例。
Math.abs() is a function in math library of JavaScript that is used to find the absolute value of the given number.
Math.abs()是JavaScript数学库中的函数,用于查找给定数字的绝对值。
Syntax:
句法:
Math.abs(value);Parameter(s):
参数:
value – It represents the value whose absolute value to be found.
值 –它表示要找到其绝对值的值。
Return value:
返回值:
The return type of this method is number, it returns the absolute value of the given value.
此方法的返回类型为number ,它返回给定值的绝对值。
Examples 1: Valid inputs of the method
示例1:方法的有效输入
console.log(Math.abs(98)) console.log(Math.abs(-34.56)) console.log(Math.abs("-65"))Output
输出量
98 34.56 65Example 2: Input values that are invalid
示例2:输入值无效
console.log(Math.abs("Include Help")) console.log(Math.abs([45, 65, 576])) console.log(Math.abs([]))Output
输出量
NaN NaN 0翻译自: https://www.includehelp.com/code-snippets/math-abs-method-with-example-in-javascript.aspx
创作挑战赛新人创作奖励来咯,坚持创作打卡瓜分现金大奖总结
以上是生活随笔为你收集整理的JavaScript中带有示例的Math.abs()方法的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 有道词典总显示无法连接服务器,有道词典无
- 下一篇: JavaScript中带有示例的Math