- Notifications
You must be signed in to change notification settings - Fork 3.3k
Open
Description
列如:
// 实现一个 map 函数 const targetData = { a: 2, b: 3, c: 4, d: 5 }; const objMap = (obj, fn) => { if (typeof fn !== "function") { throw new TypeError(`${fn} is not a function !`); } return JSON.parse(JSON.stringify(obj, fn)); }; objMap(targetData, (key, value) => { if (value % 2 === 0) { return value / 2; } return value; }); // {a: 1, b: 3, c: 2, d: 5}
参考:
zhuziqingdemao, fengyun2, NieZhuZhu, Linefate, narutooturan and 5 morethreeneedone, zhnghijin and illusionno
Metadata
Metadata
Assignees
Labels
No labels