-
-
Save shuhaibzahir/51c654f7968bec823303fa4f6bc81123 to your computer and use it in GitHub Desktop.
Revisions
-
jingsu96 created this gist
Jul 24, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ const reducer = (acc, val) => acc + val; // string reducer('Hello', ', World'); // Hello, World // number reducer(5, 20); // 25 // object const objectReducer = (acc, val) => ({ ...acc, ...val }); const myInfo = { name: 'Jing', email: '[email protected]', }; objectReducer({ ...myInfo }, { phone: '0912345678' }); // {name: "Jing", email: "jingmultiplefive@gmail.com", phone: "0912345678"}