O'Reilly logo

Mastering Javascript Functional Programming : Become skilled with Functional Programming in JavaScript by applying Javascript concepts to real world development problems by Federico Kereki

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Continuation passing style

If we have recursive calls stacked too high, we already know that our logic will fail. On the other hand, we know that tail calls should alleviate that problem... but don't, because of browser implementations! However, there's a way out for this. Let's first consider how we can transform recursive calls into tail calls, by using a well-known FP concept, continuations, and we'll leave the problem of solving TCO limitations for the next section. (We mentioned continuations in the Callbacks, promises, and continuations section of Chapter 3, Starting Out With Functions - A Core Concept, but we didn't go into detail at that point.)

In FP parlance, a continuation is something that represents the state of a process and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required