The value to check.
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)
}
Generated using TypeDoc
Checks if a value is
typeof function
.