You can use the immediately called function function expression:
(function updateIconPathRecorsive(item) { if (item.iconSrc) { item.iconSrcFullpath = 'some value..'; } _.each(item.items, updateIconPathRecorsive); })(json);
But your snippet is also beautiful and will not cause problems in IE .
There is no recursive wrapper function to underline, and it does not provide a Y-combinator . But if you want, you can easily create it yourself :
_.mixin({ recursive: function(obj, opt, iterator) { function recurse(obj) { iterator(obj); _.each(obj[opt.children], recurse); } recurse(obj); } });
Bergi source share