Proposal: Syntax sugar for single exit and early exit functions.

Biju bijumaillist at gmail.com
Mon Nov 17 21:50:38 PST 2014


On 17 November 2014 11:29, Alex Kocharin <alex at kocharin.ru> wrote:
>
> If you do the same stuff after each function, some functional programming
> could help:
>
> function someValidationProcess() {
>   ;[doStuff, doAnotherStuff, doYetAnotherStuff, doMoreStuff]
>     .forEach(function(fn) {
>       fn()
>       doCleanUp_1()
>       doCleanUp_2()
>     })
> }
>
> In this case doStuff would have to set a flag instead of condition_1()
> probably.

Just want to add, usually in corporate world a .Net or Java developer
is who code JavaScript. The code above may be little complex for them.


More information about the es-discuss mailing list