you can replace a line like this:
SomeEmitter.on('message', function(message)    {    console.log(message)    });
to:
SomeEmitter.on('message',    message    =>    console.log(message));
Another important feature of arrow functions is they are not assigned their own this —arrow functions inherit this from the call site.
the following code does not work:
function    Counter()    {
    this.count    =    0;
    setInterval(function()    {
        console.log(this.count++);
    },    1000);
}
new    Counter();

The function within setInterval is being called in the context of setInterval , rather than the Counter object, so this does not have any reference to count.

With arrow functions, this is assigned at the point of definition.
setInterval(()    =>    {    //    arrow    function    to    the    rescue!
console.log(this);
console.log(this.count++);
},    1000);
//    Counter    {    count:    0    }
//    0
//    Counter    {    count:    1    }
//    1
//    ...

results matching ""

    No results matching ""