The ECMAScript 6 standard added many new features to the JavaScript language, including a new arrow function notation.
At the moment I transpile my code to es6. Now there are sometimes two options. And I wonder which one is the better.
Use a named function if possible:
document.getElementById('rotate').addEventListener('change', function rotate() {
rotate(parseInt(this.value, 10));
});
Use a arrow function if possible:
document.getElementById('rotate').addEventListener('input', (event) => {
rotate(parseInt(event.target.value, 10));
});
Up to know I now this
named function
- It is possible to see the function name in an error stack.
Arrow functions
- Simple syntax.
Are there any other advantages or disadvantages