.map()(or any other array iteration method like
.forEach() or a loop. In general, use the array methods for their purpose:
.map- I have an array, I another array where each item is based on the first one
.mapbut I use it when each new item also an array
.filter- I have an array, I need less of it
.find- I have an array, I need one item from it
.findIndex- I have an array, I need the index of an item
.some- I have an array, I need to check if at least one item passes a check
.every- I have an array, I need to see if all items pass a check
.forEach- I have an array, I need to do something with each item. Usually I don't want to return anything.
.reduceRight- I have an array, I need to make it into "one value". I'll have to check if I really need to use reduce for this.
do..whileloops if the problem can't (or doesn't need to) fit into one of the above.
- Using regular expressions when you need "something with text" instead of parsing, simple string manipulation, or basic arithmetic, and so on.
- Unformatted code.
Member for 1 year, 10 months
4 profile views
Last seen Jun 3 '19 at 10:51
- Stack Overflow 11.2k 11.2k 66 gold badges2828 silver badges4141 bronze badges
- Worldbuilding 4.5k 4.5k 11 gold badge1111 silver badges3535 bronze badges
- Science Fiction & Fantasy 771 771 77 silver badges1616 bronze badges
- Code Review 413 413 33 silver badges1010 bronze badges
- Information Security 322 322 33 silver badges99 bronze badges
- View network profile →
Top network posts
- 70 Why would people bury their dead in tombs when they might become zombies?
- 56 Where could a vampire get blood without harming people?
- 40 Origin of genies (from lamps) having a three wish limit?
- 29 What flaw keeps the mimics out and keeps the humans in?
- 22 How would sword design change if the aim was to cause as much immediate bleeding as possible?
- 19 How could battle-runes be made inaccessible to magic users?
- View more network posts →