objects.findLastKey
jkvyff opened this issue · 1 comments
jkvyff commented
FindLastKey will return the key value of the last key whose property value it encounters that matches or returns true for the predicate
Checklist
- implementation
- tests
- jsdoc
Details
A slight amalgam of version 3 and 4 of Lodash's implementation, with allowing for both array selection notation as well as a 'this' argument.
const users = {
'barney': { 'age': 36, 'active': true },
'fred': { 'age': 27, 'active': false },
'pebbles': { 'age': 40, 'active': false }
};
Objects.findKey(users, function(chr) {
return chr.age > 30;
});
// => 'pebbles' (iteration order is not guaranteed)
Objects.findKey(users, { 'age': 27, 'active': false });
// => 'fred'
Objects.findKey(users, ['active', false]);
// => 'pebbles'
Objects.findKey(users, 'active');
// => 'barney'
References
evanplaice commented
Added in v0.64