Skip to content

Commit

Permalink
Tweak _.pairs.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Jul 24, 2013
1 parent 1205c4e commit a2d4c49
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,18 +757,18 @@
var keys = _.keys(obj);
var values = [];
for (var i = 0, l = keys.length; i < l; i++) {
values[i] = obj[keys[i]];
values[i] = obj[keys[i]];
}
return values;
};

// Convert an object into a list of `[key, value]` pairs.
_.pairs = function(obj) {
var keys = _.keys(obj),
l = keys.length,
pairs = Array(l);
for (var i = 0; i < l; i++){
pairs[i] = ([keys[i], obj[keys[i]]]);
var keys = _.keys(obj);
var length = keys.length;
var pairs = new Array(length);
for (var i = 0; i < length; i++) {
pairs[i] = [keys[i], obj[keys[i]]];
}
return pairs;
};
Expand Down

0 comments on commit a2d4c49

Please sign in to comment.