Sunday, 7 May 2017

Is it safe to use Generator function instead of normal function?

They are the same when yield is absent, of course not the same at the running phase.

function* add(x, y) {
    return x + y;
}  

var it = add(2, 3); 

it.next();

and

function add(x, y){
    return x + y;
}

add(2, 3);

As a habit, Is it safe and Okay to use them instead of normal functions? despite of performance.



via Mehdi Raash

No comments:

Post a Comment