const double = x => x * 2; function mapObject(fn, obj) { for (let i in obj) { if (obj.hasOwnProperty(i)) { obj[i] = double(obj[i]); } } return obj; } let obj = mapObject(double, {x: 1, y: 2, z: 3}) alert(JSON.stringify(obj, "", 4));