Skip to Content
Mastering JavaScript Functional Programming - Second Edition
book

Mastering JavaScript Functional Programming - Second Edition

by Federico Kereki
January 2020
Intermediate to advanced
470 pages
11h 13m
English
Packt Publishing
Content preview from Mastering JavaScript Functional Programming - Second Edition

Continuation passing style

The preceding code, in which you call a function but also pass another function that is to be executed when the input/output operation is finished, can be considered a case of continuation passing style (CPS). What is this technique of coding? One way of looking at it is by thinking about the question: how would you program if using the return statement was forbidden?

At first glance, this may appear to be an impossible situation. We can get out of our fix, however, by passing a callback to the called function, so that when that procedure is ready to return to the caller, instead of actually returning, it invokes the passed callback. By doing this, the callback provides the called function with the way to continue ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming

Mastering JavaScript Functional Programming

Federico Kereki

Publisher Resources

ISBN: 9781839213069Supplemental Content