On the first glance it seems great, but much more complex to understand and debug.
The if tree was certainly not pretty, but straightforward - it did its thing. It was something that could be given to an average developer to work on and improve.
The refactored code will require someone that's not just an average developer - if only because you need to read the article to understand it if you're not familiar with javascript, while the initial code needed only a glance to understand what it did.
IMHO, that's just complexity for complexity sake - unless you have plans to take advantage of the new flexibility it provides.
(and if you have to find, hire and pay that 'better than average' person, it might not be such a good thing.)
This is not written in javascript, it is ruby.
And I think your developer is way below average if he can't understand the pattern used in the refactored code.
The if tree was certainly not pretty, but straightforward - it did its thing. It was something that could be given to an average developer to work on and improve.
The refactored code will require someone that's not just an average developer - if only because you need to read the article to understand it if you're not familiar with javascript, while the initial code needed only a glance to understand what it did.
IMHO, that's just complexity for complexity sake - unless you have plans to take advantage of the new flexibility it provides.
(and if you have to find, hire and pay that 'better than average' person, it might not be such a good thing.)