DEV Community

Discussion on: Better loops in JavaScript

asparallel profile image

Some notes:

Beyond the 1:1, x can be represented as y comparison, it's important to note the behavior that occurs as well.

The important concept and takeaway here is we should as developers prefer the collection interface methods to imperative looping structures. Concepts this topic should lead into:

  • lazy execution
  • loop "merging"
  • declarative composition
  • monadic execution
  • guaranteed sequence of execution that avoids side effects and strongly conveys intent

Extra reading material:
“Stop Writing for-loops (lazy evaluation)” by William Carroll

kartik2406 profile image
Kartik Malik Author

Thanks for the link it's a nice read to get into performant code :).