I want to see if my understanding is correct: the functionality of the function
keyword was divided up between classes and Arrow functions in es6.
First, in the case of anonymous functions, I see no advantage in using function() {...}
over Arrow functions, especially given the this
binding in Arrow functions.
For non-anonymous functions that are not constructors, they can be declared as Arrow functions bound to a name. Given the differences in hoisting and perhaps readability, I suppose it is somewhat a matter of opinion whether using Arrow functions is strictly superior.
For functions that are constructors, classes may be used instead.
So is it correct by modern practices to say that the function
keyword need never be used, or even more strongly, should never be used?
EDIT: To be clear, I am aware of the differences between function declarations, function expressions, and Arrow functions. I am not meaning to suggest that we can go through non es6 JS and blindly replace functions decs/exprs with Arrow functions. My question is whether when writing new applications in JavaScript, if there is ever a reason to use the function
keyword, and if it my understanding is correct that the utility of the function
keyword can be thought of as split between classes and Arrow functions.