menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

What is ge...
source image

Dev

4d

read

569

img
dot

Image Credit: Dev

What is generator function in JavaScript? and How does it work?

  • A generator function in JavaScript is special type of function that can be paused and resumed during its execution.
  • It is defined using function* syntax and uses the yield keyword to produce values sequentially.
  • When a generator function is called, it returns an iterator object that has a next() method to control the execution.
  • The yield keyword is used to produce a value and pause the generator, and next() resumes the execution from the paused state.

Read Full Article

like

3 Likes

For uninterrupted reading, download the app