jty
    Preparing search index...

    Function isFn

    • Checks if a value is a function

      This is a type-safe equivalent to typeof x === 'function'.

      If you are using TypeScript and you know the function signature, you can provide the generic T for your guard.

      Type Parameters

      • T extends Function

      Parameters

      • x: unknown

        The value to check. It can be any value, including static methods, but not getters or setters.

      Returns x is T

      isFn(() => {}); // => true
      isFn(Array.isArray); // => true
      isFn(function () {}); // => true
      isFn(Function); // => true
      isFn(HTMLElement); // => true