Search code examples
javascriptgeneratorarrow-functions

Can I use generator-function with arrow function?


I wander if it's possible to use arrow function with generators like this:

app.use( *() => {
    ...body of function
});

Thanks!


Solution

  • No, it's not possible to make it shorter than described in the documentation:

    function* name([param[, param[, ... param]]]) {
       statements
    }
    

    Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*