Created
July 27, 2015 20:36
-
-
Save rajeshsegu/fdbec81612c631dfc459 to your computer and use it in GitHub Desktop.
Revisions
-
rajeshsegu created this gist
Jul 27, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ _.mixin({ /* * Walk trough every <key, value> in a given object or array * Usage: * var obj = {a: 1, b: 2, c: {d: 3, e: 4}} * _.walk(obj, function(value, key, obj){ * console.log(value); * }); * //Output: 1, 2, 3, 4 */ walk: function(obj, iterator, context){ _.each(obj, function(value, key){ if(_.isObject(value)){ _.walk(value, iterator, context); }else{ iterator.call(context, obj[key], key, obj); } }); } });