static isNumber()

Checks the provided value of any type whether is an instance of `Number` of any or the given primitive value

Number.isNumber()

The static isNumber() method checks the provided value of anyarrow-up-right type whether is an instance of Number of any or the given primitive value.

number.class.ts
public static isNumber<Value extends number>(
  value: any,
  numberValue?: Value
): value is Number<Value> {
  return (
    typeof value === 'object' &&
    value instanceof this &&
    (typeof numberValue === 'number' ? value.valueOf() === numberValue : true)
  );
}

Generic type variables

A generic type variable indicates captured type of the supplied numberValue via the return type.

Parameters

The value of anyarrow-up-right type to test against the Number instance.

numberValue?:Value

Optional number of the generic type variable Value to check if it's the primitive value of the given value.

Return type

value is Number<Value>

The return type is a booleanarrow-up-right resulting from its statement indicating the value is the Number object that takes the generic type variable Value.

Returns

The return value is a booleanarrow-up-right indicating whether the provided value is an instance of Number of any or the given numberValue.

Example usage

Last updated