Added default value to _.result

This commit is contained in:
pistacchio
2014-01-16 18:54:20 +01:00
parent c721acc2fa
commit e983f93859
2 changed files with 18 additions and 3 deletions

View File

@@ -6600,6 +6600,17 @@
deepEqual(actual, expected);
});
test('should return the default value if key is not found', 2, function() {
var object = {
'a': 1,
'b': 2
}
strictEqual(_.result(object, 'c', 3), 3);
strictEqual(_.result(object, 'c'), undefined);
});
}());
/*--------------------------------------------------------------------------*/