eran eran - 2 months ago 21
Node.js Question

What is the "=>" syntax in nodejs?

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?


() => 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.