Skip to content

Commit

Permalink
Loops.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Mar 4, 2014
1 parent 836b9b8 commit 1aff8be
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,10 @@
_.pick = function(obj, iterator, context) {
var result = {};
if (_.isFunction(iterator)) {
each(obj, function(value, key) {
for (var key in obj) {
var value = obj[key];
if (iterator.call(context, value, key, obj)) result[key] = value;
});
}
} else {
var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
for (var i = 0, length = keys.length; i < length; i++) {
Expand All @@ -878,9 +879,10 @@
_.omit = function(obj, iterator, context) {
var result = {};
if (_.isFunction(iterator)) {
each(obj, function(value, key) {
for (var key in obj) {
var value = obj[key];
if (!iterator.call(context, value, key, obj)) result[key] = value;
});
}
} else {
var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
for (var key in obj) {
Expand Down

0 comments on commit 1aff8be

Please sign in to comment.