JSFiddle - React, Tailwind, and code Playground
by Paco86
JavaScript
mapCopy = (object, callback) => {
return Object.keys(object).reduce(function (output, key) {
output[key] = callback.call(this, object[key]);
return output;
}, {});
}
const obj1 = {
name: {
firstName: 'p'
}
}
const obj2 = mapCopy(obj1);
alert(obj1.name === obj2.name);