Yes, there are cases when arrow functions are useful: when small functions are used inline, like this:
var numbers = [1, 2, 3, 4].map(x => x * x);
var bestUsers = users.filter(u => u.getRating() > 100);
But for a case when you have a large non-anonymous function, `function` keyword suits better. You don't need to use `const` keyword just becase it is something trendy now.
In your example, the code with arrow functions is smaller, but it is not more readable. Because there is no indentation, it is difficult to understand how code is nested. I cannot read that.
It can be rewritten using `deferred` pattern:
var deferred = new Deferred;
methodOne(data, function (error, response) {
if (erorr) {
deferred.reject(error);
} else {
deferred.resolve(response);
}
});
return deferred.getPromise();
This way we can get rid of a callback in the Promise constructor. Please note that our code now looks sequential and we clearly see what happens after what. Asynchronous code is difficult to write and read; therefore we must put an extra effort to make it easier.
In my opinion it is generally bad idea to nest more that 1-2 levels of functions inside each other.