mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Issue #2 -- each now calls iterator with (value, key, list) when iterating over javascript objects
This commit is contained in:
@@ -26,7 +26,7 @@ $(document).ready(function() {
|
||||
answers = [];
|
||||
var obj = {one : 1, two : 2, three : 3};
|
||||
obj.constructor.prototype.four = 4;
|
||||
_.each(obj, function(pair){ answers.push(pair.key); });
|
||||
_.each(obj, function(value, key){ answers.push(key); });
|
||||
equals(answers.join(", "), 'one, two, three', 'iterating over objects works, and ignores the object prototype.');
|
||||
delete obj.constructor.prototype.four;
|
||||
|
||||
@@ -136,7 +136,7 @@ $(document).ready(function() {
|
||||
ok(_.isArray(_.toArray(arguments)), 'arguments object converted into array');
|
||||
|
||||
var numbers = _.toArray({one : 1, two : 2, three : 3});
|
||||
equals(_.pluck(numbers, '0').join(', '), 'one, two, three', 'object flattened into array');
|
||||
equals(numbers.join(', '), '1, 2, 3', 'object flattened into array');
|
||||
});
|
||||
|
||||
test('collections: size', function() {
|
||||
|
||||
Reference in New Issue
Block a user