DEV Community

loading...

Discussion on: Better loops in JavaScript

Collapse
asparallel profile image
AsParallel

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 link.medium.com/f5fDWslBHS

Collapse
kartik2406 profile image
Kartik Malik Author

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