Function isNumeric #
测试一个值是否为数字值。
如果输入是数组或矩阵,函数将逐个元素进行评估。
Syntax #
math.isNumeric(x)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
* | 要测试的值 |
Returns #
| Type | Description |
|---|---|
| boolean | 当 x 是 number、BigNumber、Fraction 或 boolean 时返回 true。对于其他类型返回 false。在未知类型的情况下抛出错误。 |
Throws #
Type | Description —- | ———–
Examples #
math.isNumeric(2) // returns true
math.isNumeric('2') // returns false
math.hasNumericValue('2') // returns true
math.isNumeric(0) // returns true
math.isNumeric(math.bignumber('42')) // returns true
math.isNumeric(math.bigint('42')) // returns true
math.isNumeric(math.fraction(4)) // returns true
math.isNumeric(math.complex('2-4i')) // returns false
math.isNumeric([2.3, 'foo', false]) // returns [true, false, true]
另请参阅 #
isZero, isPositive, isNegative, isInteger, hasNumericValue, isFinite, isBounded