You must know the iterator and generator

generator is a special iterator, which can replace the implementation of iterator to make the code more conciseWhat is an iteratorAn iterator is called an iterator. It is an object used to help traverse a data structure. This object needs to comply with the iterator protocol.The iterator protocol requires the implementation of the next method, ...

Added by scott56hannah on Tue, 28 Dec 2021 01:35:14 +0200

js - various for loop analysis

The three most used structures in our development are: sequential structure, selection structure and circular structure. There are various loop structures in JavaScript, such as the most common for loop, forEach loop, for... In loop and for... of loop; of course, there are other loops such as while, but this article only discusses various for l ...

Added by zab329 on Fri, 24 Dec 2021 00:18:25 +0200

generator, iterable and iterator are confused

generator, iterable and iterator are confused Through the list generation formula, we can directly create a list. However, due to memory constraints, the list capacity must be limited. Moreover, creating a list containing 1 million elements not only takes up a lot of storage space, but if we only need to access the first few elements, the spac ...

Added by killfall on Fri, 26 Nov 2021 15:58:55 +0200