For almost every functional or architectural application component, there are a plethora of ‘as a service’ offerings. We see infrastructure as a service (IaaS), backend as a service (BaaS), SaaS…
General JavaScript functions can’t be interrupted in the middle of a function execution, once the function is invoked until function execution completes. (i.e… Either by returning some value from the function or throwing error inside the function).
When we want to execute functions which can be interrupted or which can execute after a while once execution is started then ECMAScript-6 came up with a new type of functions called Generator Functions.
A generator function is a function which can be interrupted or which can execute after a while once the execution is started is called Generator Functions.
Generator functions are declared the same as normal functions of JavaScript but “function” keyword is suffixed with asterisk(*) symbol or asterisk prefixed with the function name.
There are two ways of declaring generator functions
2. Function name prefixed with asterisk(*)
Before going to understand more on generator functions let us try to understand about “yield” keyword of ECMAScript-6
“Done” property returns true in 2 cases
Other than this three cases the “done” property returns false.
Output
From the above “gen” is an iterator object.
2. When the function is having a return statement
Output
Conclusion
Traveling the world is one of many people’s dream. Not only to spend time on their holiday, but also to learn more about communities in all corners of the world. Since this pandemic has taken place…
The Nazis established the Hitler Youth and the League of German Girls to manipulate teenagers. They encouraged sexuality to increase the population, however, things got out of control!
Google Apps Script is an effective tool for automating tasks and workflows in Google Suite. Its standout feature is the ability to generate triggers — scripts that activate automatically in response…