Advanced-Frontend / Daily-Interview-Question

我是依扬(木易杨),公众号「高级前端进阶」作者,每天搞定一道前端大厂面试题,祝大家天天进步,一年后会看到不一样的自己。
https://muyiy.cn/question/
27.43k stars 3.29k forks source link

实现 #572

Open hello-tsai opened 2 years ago

hello-tsai commented 2 years ago

const test = { a: 1, b: 2, c: 3 }

const ObjMap = (obj, fn) => { const keys = Object.keys(obj) for (let i =0 ; i < keys.length; i++) { obj[keys[i]] = fn(obj[keys[i]]) } return obj } console.log(ObjMap(test, item => item += 1))