Loop executes the same code of block again and again. Loop is a control flow statement for specifying iteration, which allows code to be executed repeatedly. Repetitive task within a program to save time and effort.
📺 The video in this post was made by Programming with Mosh
The origin of the article: https://www.youtube.com/watch?v=s9wW2PpJsmQ&list=PLTjRvDozrdlxEIuOBZkMAK5uiqp8rHUax&index=8
🔥 If you’re a beginner. I believe the article below will be useful to you ☞ What You Should Know Before Investing in Cryptocurrency - For Beginner
⭐ ⭐ ⭐The project is of interest to the community. Join to Get free ‘GEEK coin’ (GEEKCASH coin)!
☞ **-----CLICK HERE-----**⭐ ⭐ ⭐
Thanks for visiting and watching! Please don’t forget to leave a like, comment and share!
An iterator is a new concept of ES6. An Iterator is an object that lets us iterate through an Array, an Object, a String, or even custom Objects.
The Iterator allows us to effectively loop over a collection of objects like an array, string, objects, or other data structures.
Okay, you might be wondering, what even are iterators and iterable objects? An iterable is a sequential data structure that can be iterated over. Iterables can also have their own access method, which defines its iterator. This allows iterables to be publicly accessible. An iteratoris like a pointer that traverses the collection in a particular way. As we will get into in a bit, these new custom iterators in ES6 can loop through more than just a simple array.
This is a lot of jargon that I will break down in a few minutes with an example. But for starters, let’s take a look at the default use of ES6 iterators in the for-of loop.
In ES5 and before, we’re used to seeing for and while loops to iterate over arrays or strings. Now, with ES6, we can hop around an array or a string without having to set the parameters for these loops. The for-of loop by default knows how to iterate over these data types sequentially: