0

If we take the following example:

function makeCounter() {
    let i=0;
    return function() {
        console.log(++i);
    }
}
c = makeCounter();
c();
c();

In the above, we could change the return to use an arrow function if we wanted:

function makeCounter() {
  let i=0;
  return () => console.log( ++i );
}
c = makeCounter();
c();
c();

Is the arrow function essentially a way to rewrite a function expression with more-compact terminology? Or does it server other purposes as well?

David542
  • 101,766
  • 154
  • 423
  • 727

0 Answers0