GitHub 6248★

Check if a value is a function

JavaScript version

const isFunction = (v) => ['[object Function]', '[object GeneratorFunction]', '[object AsyncFunction]', '[object Promise]'].includes(Object.prototype.toString.call(v));

Examples

isFunction(function () {}); // true
isFunction(function* () {}); // true
isFunction(async function () {}); // true
Follow me on and to get more useful contents.