I like that way, but not if it needs to be used regularly in events through a single js block...
Lets just say its fine, but if you have performance woes, avoid jsblocks inside loops at all costs. As a replacement for a custom action, for example, in a foreach obj loop, calling the function via js is like 300x slower than by event, as far as the raw overhead goes.
On the other hand, if you have a function call from within a jsblock that is doing the iterating, that will be faster.
TLDR is don't loop outside of a js block.