Skip to content
Search

Continuation-passing style

lastmod 2018-08-31created 2015-07-302 edits

Cons

The CPS (Continuation-passing style) approach, in which a program keeps passing what to do next as a callback, can hurt readability.

step1(function (value1) {
    step2(function (value2) {
        step3(function (value3) {
            step4(function (value4) {
                step5(function (value5) {
                    step6(function (value6) {
                        // Do something with value6
                    });
                });
            });
        });
    });
});

See also

Favorite site

author Zer0 sitemap