A method that maps only the values of a javascript object, which is a set of key/value pairs, like the map function of an array.
const entriesMap = (object, callbackfn) => {
const entries = Object.entries(object).map(e => callbackfn(e))
return Object.fromEntries(entries)
}
const valuesMap = (object, callbackfn) =>
entriesMap(object, ([k, v]) => [k, callbackfn(v)])
export { entriesMap, valuesMap }
Top comments (0)