This isn't directly an answer about the efficiency of anonymous functions, but more about the coding style, since I get the impression that this is what the OP really cares about. (Especially pre-edit, the question seemed to be more "I think this style is unreadable, so people must be doing it for efficiency, am I right?")
There is a balance to be struck in all code between verbosity and conciseness. They are opposites, but neither is all good; they both have disadvantages.
Code that is too verbose is hard to read because reading code takes time, time in which you forget what you previously read. In addition, verbose code tends to contain additional information (such as the name of a non-anonymous function) that competes for space in your short-term memory with other information. Finally, it can introduce non-locality, e.g. if you introduce another function that you now have to go look for in order to understand the code.
Code that is too concise is hard to read because you have to keep to many details in your head without having a moniker to refer them by, and because lots of concise code clumps up, making it easier to lose your place in the code while reading. And it requires you to understand all the details of the code, whereas a well-named extracted function can often be treated as a black box.
Somewhere in the middle is the point of maximum readability.
Here's an example that just involves mathematical calculations. Let's say I have a function that calculates something simple, like celsius to fahrenheit conversion:
function celsiusToFahrenheit(celsius) {
return celsius * (9.0/5.0) + 32;
}
Clear and simple. There's a scaling factor and an offset. Some purists might argue that these should be named constants, but I don't see the point; the function is a one-liner and the purpose of these numbers is obvious, and they're not going to change.
However, I could write it more verbosely:
function celsiusToFahrenheit(celsius) {
let scaledCelsius = celsius * (9.0/5.0);
return scaledCelsius + 32;
}
Here I took an intermediate result of the calculation and assigned it a name. I shifted more towards verbosity. Did it improve readability? You now have more code to read, and I had to invent an additional name which you have to remember while reading the code. I'd say readability got worse.
Here's a different example. This formula calculates an approximation of radio signal pathloss from a transmitter antenna to a point in space, tuneable with a bunch of user-specified coefficients. This is a simplification of the real formula.
function pathloss(heightAntenna, heightDevice, distance, frequency, coefficients) {
// formula uses log scale
frequency = log10(frequency);
heightAntenna = log10(heightAntenna);
distance = log10(distance * 0.001);
return
(coefficients.A0 + coefficients.A1 * frequency - coefficients.A2 * heightAntenna) -
((coefficients.a0 * frequency - coefficients.a1) * heightDevice -
coefficients.a2 * frequency + coefficients.a3) +
coefficients.C0 * pow(frequency - coefficients.C1, 2) - coefficients.C2 +
(coefficients.B0 - coefficients.B1 * frequency) * distance;
}
I think you'll agree that this is completely unreadable. Here, splitting it up in parts really helps.
function pathloss(heightAntenna, heightDevice, distance, frequency, coefficients) {
// formula uses log scale
frequency = log10(frequency);
heightAntenna = log10(heightAntenna);
distance = log10(distance * 0.001);
// names are somewhat weird, that's the way they're written in the
// reference book this is based on
let a = (coefficients.a0 * frequency - coefficients.a1) * heightDevice -
coefficients.a2 * frequency + coefficients.a3;
let A = (coefficients.A0 + coefficients.A1 * frequency -
coefficients.A2 * heightAntenna) - a;
let C = coefficients.C0 * pow(frequency - coefficients.C1, 2) - coefficients.C2;
let B = (coefficients.B0 - coefficients.B1 * frequency) * distance;
return A + C + B;
}
This is still mathematically challenging, but at least it's broken up into chunks, making it much easier to keep track of which parts are added to which, something that required careful tracking of parentheses in the original version.
Anonymous functions are subject to the same trade-off. Using them improves locality. Overusing them (especially nesting them) makes program flow hard to track. It's up to you to find a balance.