Menu

gitpiper

isGeneratorFunction javascript Code Snippet in 2023

typefunctionintermediate

Last Updated: 2 February 2023

Checks if the given argument is a generator function.

  • Use Object.prototype.toString() and Function.prototype.call() and check if the result is '[object GeneratorFunction]'.
const isGeneratorFunction = val => Object.prototype.toString.call(val) === '[object GeneratorFunction]';
isGeneratorFunction(function() {}); // false isGeneratorFunction(function*() {}); // true

javascript snippet similar to isGeneratorFunction For You in February 2023

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2023 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️