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:

Build A React AI Image Generator With Hugging Face Diffusers

Build a React AI image generator with Hugging Face Diffusers

Build a React-based AI image generator app offline using the Hugging Face Diffusers library and Stable Diffusion XL.

Andrew Baisden
May 29, 2025 â‹… 10 min read
Gemini 2.5 and the future of AI reasoning for frontend devs

Gemini 2.5 and the future of AI reasoning for frontend devs

Get up to speed on Google’s latest breakthrough with the Gemini 2.5 model and what it means for the future of frontend AI tools.

Chizaram Ken
May 29, 2025 â‹… 5 min read
Exploring The Top Rust Web Frameworks

Exploring the top Rust web frameworks

In this article, we’ll explore the best Rust frameworks for web development, including Actix Web, Rocket, Axum, warp, Leptos, Cot, and Loco.

Abiodun Solomon
May 28, 2025 â‹… 11 min read
How To Use The CSS Cursor Property

How to use the CSS cursor property

A single line of CSS can change how users feel about your UI. Learn how to leverage the cursor property to signal intent, improve interaction flow, and elevate accessibility.

Chizaram Ken
May 28, 2025 â‹… 6 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