isFunction
Using
This function determines whether the given value is a real function.
- Returns
true
for standard functions, arrow functions, async, generator, class constructors, built-ins, andFunction
instances. - Returns
false
for all non-function values, including objects with.call
, arrays, primitives, and browser-specific quirks likedocument.all
.
Arguments
Argument | Type | Description | Example |
---|---|---|---|
value | unknown | Can be any type | "text" 2 undefined |
Returns
boolean
— true
if value is a function, false
otherwise
Examples
isFunction(() => {});
// true
isFunction(async function () {});
// true
isFunction(class {});
// true
isFunction({ call: () => {} });
// false
isFunction(null);
// false
isFunction(() => () => {});
// true
isFunction('function');
// false