Skip to content

Instantly share code, notes, and snippets.

@ORESoftware
Created June 25, 2019 00:26
Show Gist options
  • Save ORESoftware/d83682d73433c79ac2c69339e3672182 to your computer and use it in GitHub Desktop.
Save ORESoftware/d83682d73433c79ac2c69339e3672182 to your computer and use it in GitHub Desktop.
spread operator to merge / mixin objects
const a = {
a: {
b: {
c: 4,
d: 'str'
}
}
};
const b = {a: {b: {c: 5}}};
console.log({...a,...b}); // { a: { b: { c: 5 } } }
// now reverse the arguments
console.log({...b,...a}); // { a: { b: { c: 4, d: 'str' } } }
@KSoto
Copy link

KSoto commented Jun 25, 2019

Oooh I see, thank you for clearing that up! I think I was ignoring the values xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment