2018-05-14
1389
#vanilla javascript
Benjamin Johnson
390
May 14, 2018 â‹… 4 min read

Using trampolines to manage large recursive loops in JavaScript

Benjamin Johnson Software engineer. Learning every day, one mistake at a time. You can find me online at benjaminjohnson.me.

Recent posts:

Justin Kitagawa Leader Spotlight

Leader Spotlight: Riding the rocket ship of scale, with Justin Kitagawa

We sit down with Justin Kitagawa to learn more about his leadership style and approach for handling the complexities that come with scaling fast.

Jessica Srinivas
Mar 29, 2024 â‹… 8 min read
Nx Adoption Guide: Overview, Examples, And Alternatives

Nx adoption guide: Overview, examples, and alternatives

Let’s explore Nx features, use cases, alternatives, and more to help you assess whether it’s the right tool for your needs.

Andrew Evans
Mar 28, 2024 â‹… 9 min read
Understanding Security In React Native Applications

Understanding security in React Native applications

Explore the various security threats facing React Native mobile applications and how to mitigate them.

Wisdom Ekpotu
Mar 27, 2024 â‹… 10 min read
Warp Adoption Guide: Overview, Examples, And Alternatives

warp adoption guide: Overview, examples, and alternatives

The warp web framework for Rust offers many enticing features. Let’s see when and why you should consider using warp in your projects.

Ukeje Goodness
Mar 26, 2024 â‹… 8 min read
View all posts

3 Replies to "Using trampolines to manage large recursive loops in JavaScript"

  1. Thanks for the article, i would argue the same as above but also without any need for the sum accumulator e.g.:

    “`
    const sumBelowRec (n) => () =>
    n === 0
    ? 0
    : n + sumBelowRec(n – 1)
    “`

  2. Accumulator is important because it will only work if you return trampoline function (same as Tail call). Otherwise you will sum up number with function.

Leave a Reply