Hint
Object spread is order-sensitive: rightmost/latest definition wins. Use this for: {...defaults, ...overrides} to safely apply user config on top of defaults.
const defaults = { color: 'red', size: 'medium', border: 'solid' };
const custom = { color: 'blue', size: 'large' };
const config1 = { ...defaults, ...custom };
const config2 = { ...custom, ...defaults };
const config3 = { ...defaults, color: 'green' };
console.log(config1.color, config1.border);
console.log(config2.color, config2.border);
console.log(config3.color, config3.border);blue solid red solid green solid
Explanation: Spread: later properties win. config1: custom spreads last β color=blue, border=solid (from defaults). config2: defaults last β color=red. config3: literal color after spread overrides defaults.color.
Key Insight: Object spread is order-sensitive: rightmost/latest definition wins. Use this for: {...defaults, ...overrides} to safely apply user config on top of defaults.