Menu

gitpiper

isGeneratorFunction javascript Code Snippet in 2024

typefunctionintermediate

Last Updated: 10 April 2024

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 April 2024

Subscribe to our Newsletter

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

© 2024 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! ✌️