Yes I am just creating an anonymous function inline - since Javascript has no block scope (only function scope), this is the only way to do it.

I can break it out into a separate function and call that instead (like your latest example), if you think this is more readable.