April 2018
Intermediate to advanced
284 pages
5h 46m
English
| Tip 27 | Reduce Loop Clutter with for...in and for...each |
In this tip, you’ll learn how to maintain clarity with loops over iterables using for...in and over objects using for...of.
Hopefully by now you’re convinced that array methods can handle most of your iterations in clear and predictable ways. Sometimes, however, an array method may be either inefficient or cumbersome.
There may be times you want to exit out of a loop when a result doesn’t match what you need. In those cases, it makes no sense to keep iterating over information.
Alternatively, an array method may be overly complex when you’re working with a collection that isn’t an array. Remember that just because a structure isn’t an array doesn’t mean you can’t use array methods. If ...
Read now
Unlock full access