es-toolkit/docs/reference/predicate/isFunction.md

34 lines
880 B
Markdown
Raw Normal View History

# isFunction
Checks if `value` is a function.
This function returns `true` if `value` is a function, and `false` otherwise.
This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to a function.
## Signature
```typescript
function isFunction(value: unknown): value is (...args: never[]) => unknown;
```
### Parameters
- `value` (`unknown`): The value to check if it is a function.
### Returns
(`value is (...args: never[]) => unknown`): Returns `true` if the value is a function, otherwise `false`.
## Examples
```typescript
import { isFunction } from 'es-toolkit/predicate';
console.log(isFunction(Array.prototype.slice)); // true
console.log(isFunction(async function () {})); // true
console.log(isFunction(function* () {})); // true
console.log(isFunction(Proxy)); // true
console.log(isFunction(Int8Array)); // true
```