Function isInteger

  • Checks if value is an integer.

    This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to number.

    Parameters

    • Optionalvalue: unknown

      The value to check

    Returns value is number

    true if value is integer, otherwise false.

    isInteger(3); // Returns: true
    isInteger(Infinity); // Returns: false
    isInteger('3'); // Returns: false
    isInteger([]); // Returns: false