Value is async function

JavaScript, Type, Function · Oct 20, 2020

Checks if the given argument is an async function.

const isAsyncFunction = val =>
  Object.prototype.toString.call(val) === '[object AsyncFunction]';
isAsyncFunction(function() {}); // false
isAsyncFunction(async function() {}); // true

Written by Angelos Chalaris

I'm Angelos Chalaris, a JavaScript software engineer, based in Athens, Greece. The best snippets from my coding adventures are published here to help others learn to code.

If you want to keep in touch, follow me on GitHub.

More like this

  • JavaScript Function Snippets

    Learn everything about JavaScript functions with this ES6 snippet collection.

    Collection · 95 snippets

  • Value is generator function

    Checks if the given argument is a generator function.

    JavaScript, Type · Oct 20, 2020

  • Value is function

    Checks if the given argument is a function.

    JavaScript, Type · Sep 15, 2020

  • Value is string

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

    JavaScript, Type · Oct 20, 2020