Redux


Sat, 23 Nov 2024 06:36:27 GMT

Calling an API will cause side-effects, and thus a function that calls an API is considered an impure function. Read more

Shallow-merge and deep merge:

const obj1 = { a: 1, b: { x: 10, y: 20 } };
const obj2 = { b: { z: 30 } };

const shallowMerged = { ...obj1, ...obj2 }; 
console.log(shallowMerged);
// Output: { a: 1, b: { z: 30 } }

const deepMerged = deepMerge(obj1, obj2); 
console.log(deepMerged);
// Output: { a: 1, b: { x: 10, y: 20, z: 30 } }