uft
    Preparing search index...

    Function isFunction

    • Checks if a value is typeof function.

      Parameters

      • value: unknown

        The value to check.

      Returns value is Function

      true if the check passes, false otherwise.

      isFunction(() => {}) // true
      isFunction(function() {}) // true
      isFunction(async function() {}) // true
      isFunction({}) // false
      const value: { foo: string } | (() => string)

      if (isFunction(value)) {
      value // type: (() => string)
      value() // ok
      value.foo // error
      } else {
      value // type: { foo: string }
      value.foo // ok
      value() // error
      }

      // or
      if (!isFunction(value)) {
      value // type: { foo: string }
      } else {
      value // type: (() => string)
      }