I'd agree with jmrk's answer here but am reinforcing Rohan's answer.
It's worth noting that arrow functions are not only "syntactic sugar" when used in ES6 classes.
Arrow functions in classes aren't present on the prototype, but are created as a member for every object, every time that object's class is instantiated.
For example, take this class:
class ArrowFunctionMember {
i = 0;
test = () => {
this.i += 1;
}
}
That's the equivalent of doing:
class ArrowFunctionMemberEquivalent {
i = 0;
constructor () {
this.test = function () {
this.i += 1;
}
}
}
It's much easier to spot what's going on in the second example - When the class is instantiated an instance of the test
function is created with it, this can lead to much larger memory consumption (and will be inherently slower to instantiate) depending on how many objects are created.
Here's a test I made to illustrate the performance difference between instantiation speed of classes with arrow function members vs with regular function members.
So if you're not creating many objects from classes with arrow function members, the performance difference will likely be negligible. However, if you are creating a large amount of objects then consider using regular member functions instead, so you can take advantage of the prototype sharing that JavaScript objects use.