Created
October 6, 2010 14:31
-
-
Save phiggins42/613435 to your computer and use it in GitHub Desktop.
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 characters
dojo.filterObject = function(obj, filterFn, context){ | |
var ret = {}; context = context || window; | |
for(var i in obj){ | |
if(filterFn.call(context, obj[i], i, obj)){ | |
ret[i] = obj[i]; | |
} | |
} | |
return ret; | |
} |
yah it's like forEach for objects, but is actually more like array.filter in that the return of the callback is used to determine if the item should be included in the copy.
sorry... the link was to filterIn but i wrote forIn - i meant filterIn which works as you say, i blame jetlag :P
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
or... dojox.lang.functional.forIn