Is there a benefit in ES6 to doing the const foo = (whatever) => ... syntax here over just function foo(whatever) { ... }? I’m not clear if raganwald just wanted to show off that syntax, or whether there are namespace pollution benefits, or what.
There are a couple of benefits to the fat arrow syntax: implicit returns in one-liners, and lexical this bindings. In addition, a constant (const) can’t be redefined, while a function declaration can.
Is there a benefit in ES6 to doing the
const foo = (whatever) => ...syntax here over justfunction foo(whatever) { ... }? I’m not clear if raganwald just wanted to show off that syntax, or whether there are namespace pollution benefits, or what.There are a couple of benefits to the fat arrow syntax: implicit returns in one-liners, and lexical
thisbindings. In addition, a constant (const) can’t be redefined, while a function declaration can.