Skip to content

Function: isFunction()

isFunction(val): val is (arguments_: unknown[]) => unknown

Type guard to check if a value is a function.

Parameters

val

unknown

The value to check

Returns

val is (arguments_: unknown[]) => unknown

True if the value is a function

Example

typescript
const value: unknown = () => 'hello'

if (isFunction(value)) {
  // TypeScript knows value is a function
  console.log(value()) // 'hello'
}

Released under the MIT License.