2 ms·
... also custom and paremetrized iterators: class FreakyCollection { // ... *even() { // for ... iterate skipping the odd ones and
by scotty79 4y ago
... also custom and paremetrized iterators:
class FreakyCollection {
// ...
*even() {
// for ... iterate skipping the odd ones and yielding the rest one by one
}
*having(quality) {
// for ... iterate and yield just the items that have some quality
}
and usage then is as simple as:
for(let item of freakyCollection.having(42)) {