javascript
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