

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Node.js – util.types.isGeneratorObject() Method
The util.types.isGeneratorObject() method checks whether the passed value is a built-in generator object or not. If the above condition is satisfied, it returns True, else False. The return value may differ from the original source code if a transpilation tool is used.
Syntax
util.types.isGeneratorObject(value)
Parameters
- value − This input value takes input for the required parameter and checks if it's a Generator object or not.
It returns True or False based upon the input value passed.
Example 1
Create a file "isGeneratorObject.js" and copy the following code snippet. After creating the file, use the command "node isGeneratorObject.js" to run this code.
// util.types.isGeneratorObject() Demo Example // Importing the util module const util = require('util'); // Defining a generator function function* generator() { yield 1; yield 2; yield 3; } const gen = generator(); // Passing the generator object console.log("1." + util.types.isGeneratorObject(gen)); // Passing the generator function console.log("2." + util.types.isGeneratorObject(generator()));
Output
C:\home\node>> node isFloat32Array.js 1.true 2.true
Example 2
// util.types.isGeneratorObject() Demo Example // Importing the util module const util = require('util'); // Defining a generator function function* infinite() { let index = 0; while (true) { yield index++; } } const generator = infinite(); // "Generator { }" console.log(generator.next().value); // 0 console.log(generator.next().value); // 1 console.log(generator.next().value); // 2 // Passing the generator object console.log("1." + util.types.isGeneratorObject(generator)); // Passing the generator next-value function console.log("2." + util.types.isGeneratorObject(generator.next()));
Output
C:\home\node>> node isFloat32Array.js 0 1 2 1.true 2.false
- Related Questions & Answers
- How to use jQuery.getScript() method to load external js files?
- How to include multiple js files using jQuery $.getScript() method?
- HTML5 / JS storage event handler
- SVG morphing in React JS
- JS Geolocation but without prompting possible?
- Why do I need Babel JS?
- Adding Lottie animation in React JS
- SVG drawing in React JS frontend
- Why is isNaN(null) == false in JS?
- Selecting database inside the JS in MongoDB?
- Convert JS array into an object - JavaScript
- Creating a Particle Animation in React JS
- Creating a Customizable Modal in React JS
- Creating animated loading skeletons in React JS
- Finding next greater node for each node in JavaScript
- Node in Javascript
Advertisements