Add guard check to _.last()

Allows _.last() to work as expected with _.map().
This commit is contained in:
Malcolm Locke
2011-09-01 01:10:10 +12:00
parent a8f0445192
commit e449b00a26
2 changed files with 5 additions and 3 deletions

View File

@@ -30,6 +30,8 @@ $(document).ready(function() {
equals(_.last([1,2,3], 2).join(', '), '2, 3', 'can pass an index to last');
var result = (function(){ return _(arguments).last(); })(1, 2, 3, 4);
equals(result, 4, 'works on an arguments object');
result = _.map([[1,2,3],[1,2,3]], _.last);
equals(result.join(','), '3,3', 'works well with _.map');
});
test("arrays: compact", function() {