entries() returns an iterator object that is used to step through each item in the array. Object also has an entries() method that can be iterated through with a for ... of loop. With Object, this is very useful because it gives us access to both the key and the value as we're looping over the entries of an object. With Array, the key is always the index of the array, and could be accessed with a regular for loop. The fact that entries() is also available on Array, however, provides some uniformity in the language. But much more than that, there are unique use cases for iterators. Iterators consume memory only as needed. Think of them as a method for control flow. Unlike arrays, iterators do not have the static concept of length. Instead, each time an iterator runs, it calls next() until its value for done is true. A regular for loop needs to load the entire collection into memory in order to iterate over it, whereas an iterator only needs to know the current position in the collection, meaning we can stop it and start it and control when we want to move onto processing the next element. This has the ability to make processing our code more efficient on large collections. Keep this in mind if you have a large - and potentially slow - array list that you need to process in a loop. The concept is, in many ways, similar to streaming or pagination: it's much easier to consume a lot of data in small bites, as needed, instead of all at once.
Visit the website you can read more articles, find more videos, and sign up to the newsletter.
https://mackleystudios.com/
Looking for a remote freelancer?
Send me an email at contact@mackleystudios.com
Nesta página do site você pode assistir ao vídeo on-line entries() - JavaScript Array Methods duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Mackley Studios 12 Janeiro 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 204 vezes e gostou 4 espectadores. Boa visualização!