mathjs/docs/reference/functions/hasNumericValue.md
2018-11-29 20:15:40 +01:00

1.1 KiB

Function hasNumericValue

Test whether a value is an numeric value.

Syntax

math.hasNumericValue(x)

Parameters

Parameter Type Description
x * Value to be tested

Returns

Type Description
boolean Returns true when x is a number, BigNumber, Fraction, Boolean, or a String containing number. Returns false for other types. Throws an error in case of unknown types.

Examples

math.hasNumericValue(2)                     // returns true
math.hasNumericValue(0)                     // returns true
math.hasNumericValue(math.bignumber(500))   // returns true
math.hasNumericValue(math.fraction(4))      // returns true
math.hasNumericValue(math.complex('2-4i')   // returns false
math.hasNumericValue('3')                   // returns true
math.hasNumericValue([2.3, 'foo', false])   // returns [true, false, true]

See also

isZero, isPositive, isNegative, isInteger