Few languages contains feature known as while ... else.

It's very useful for special treatment of empty iterators.

In JS following code :
while (expr) {

    /* code */

} else {

    /* other code */

}

can be equivalent to :
let temp = expr ;
if (temp) {
    while (temp) {
        /* code */
        temp = expr;
    }
    } else {

        /* other code */

    }

This implementation slightly differs from Python's while-else (in Python
else block is always executed, except for break statement) but I consider
it more logical.

Pure functions

pure square(x){

    return Math.pow(x,2);

}

Pure functions are allowed to call only other pure functions. Pure
functions cannot reference any variable (but they can reference primitive
consts). Pure function always have undefined this, eval is forbidden. Every
`Math`, `Object`, `Array` or similar references always resolve to their
global value.

Calling nonpure function in any way should throw an exception.

Implementations are encouraged to parallelize these function calls whenever
it's possible (ie. `.map` on array).
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to