re: Refactoring JavaScript for Performance and Readability (with Examples!) VIEW POST


I don't know, I actually find the first example of search groups more readable. I'll try to explain why:

I the first example we read the code from top towards down. Whereas in the second example we have additional variables that actually seem to be adding more mess the code than description. In the second example developers eye must float between definitions and the actual code we are reading to get an idea what is going on.

In the first example I can clearly see that there is a two dimensional array with an object at the end. In the second example it's not obvious without carefully studying the code.


I prefer the refactored code, because from the variables names it's clear what we're working with.

I guess we need a tool jsRead to measure a code's readability with objective metrics like it's done in jsPerf with performance 😂


Thanks for weighing in! I was hoping some of these would spawn discussion 😊

code of conduct - report abuse