@rahmatsaeedi/lotide
Version:
A light-weight, simplified, & minified version of Lodash library
13 lines (10 loc) • 338 B
JavaScript
// This method returns the key of the first element predicate returns truthy. Predicate takes (object[key], key, object).
// jshint esversion : 6
const findKey = function(object, predicate) {
for (let key in object) {
if (predicate(object[key], key, object)) {
return key;
}
}
};
module.exports = findKey;