I'm wondering what is the difference between an anonymous function:
callback = function (a) {return a}
and using the "=>" notation?
callback = (a) => {return a}
Is it anything more than syntactic sugar?
I'm wondering what is the difference between an anonymous function:
callback = function (a) {return a}
and using the "=>" notation?
callback = (a) => {return a}
Is it anything more than syntactic sugar?
It is called ES6 fat arrow syntax. There is difference between them, fat arrow one automatically captured this.
() =>
is called arrow function
of Javascript, which is introduced in ECMA Script 6.
It's useful for more intuitive handling of current object context.
Reference link for new features of ECMA Script 6.
This has nothing to do with Node.js. Node.js is just a library, libraries can't introduce syntax in ECMAScript.
It's just a standard ECMAScript arrow function.
Is it anything more than syntactic sugar?
Yes. Arrow functions have lexically scoped this
.