eran eran - 1 year ago 104
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download