Value is function

JavaScript, Type, Function · Sep 15, 2020

Checks if the given argument is a function.

  • Use typeof to check if a value is classified as a function primitive.
const isFunction = val => typeof val === 'function';

isFunction('x'); // false
isFunction(x => x); // true

More like this

  • JavaScript Function Snippets

    Learn everything about JavaScript functions with this ES6 snippet collection.

    Collection · 96 snippets

  • Value is async function

    Checks if the given argument is an async function.

    JavaScript, Type · Oct 20, 2020

  • Value is generator function

    Checks if the given argument is a generator function.

    JavaScript, Type · Oct 20, 2020

  • Value is string

    Checks if the given argument is a string. Only works for string primitives.

    JavaScript, Type · Oct 20, 2020