Warning: Some posts on this platform may contain adult material intended for mature audiences only. Viewer discretion is advised. By clicking ‘Continue’, you confirm that you are 18 years or older and consent to viewing explicit content.
If you’re not married to functional code, for searching a keyed object by property for the key, you can always write:
for (const key in data) {
if (data[key].firstName === 'Frederic') {
console.log(key);
}
}
No need to transform the whole object with Object.entries, and you could turn that into a function reasonably easy, something like findKey(object, property, value) or some such.
If you’re not married to functional code, for searching a keyed object by property for the key, you can always write:
No need to transform the whole object with Object.entries, and you could turn that into a function reasonably easy, something like
findKey(object, property, value)
or some such.