this is a topic that’s close to my heart because it’s fundamental, difficult, and subtle: something as simple as a loop can expressed in vastly different ways. knowing which route to take for every situation will help you write straightforward code that reflects your ideas.
for is a classic example of the concept of 'imperative programming': a style that emphasizes telling computers what to do. there are other
styles, like declarative programming, which is telling computers
what you want - a big example of that is SQL.
some of the others are .some(), which tells you if any element of an array passes a test, .every(), which says if ever element does
some people use underscore or lodash for this. that's fine too, but it's best to use tools that do exactly what you want: the mission
of underscore is to bring other functional programming goodies
this concept, called 'immutability', is really deep. see immutable-js for an example of it taken to the extreme. the benefits of immutability,
besides simpler code, extend into performance and the ability to
undo changes to data.
for what it's worth, array.splice() is basically the reduce of mutable array functions: you can use it instead of shift, unshift,
pop, push, and slice. but nobody ever remembers the order
of arguments and the name sounds weird so they don't.