Skip to content

isNum

isNum(val): boolean

Defined in: core/utils/types.ts:41

Returns true if the value is a number, or can be read as one.

This is !isNaN(val), on purpose: options read from data-* attributes are strings (data-tooltip="delayTime:500" gives '500'), and the components validate them with this function. It is therefore true for numeric strings and also for '', null, true and []. It is not a type guard for that reason: a true result does not mean typeof val === 'number'.

unknown

Value to test.

boolean