Skip to content

Instantly share code, notes, and snippets.

@brunokrebs
Created December 28, 2017 17:02
Show Gist options
  • Save brunokrebs/71e8fba79a312413c9f5ecac7f84e27d to your computer and use it in GitHub Desktop.
Save brunokrebs/71e8fba79a312413c9f5ecac7f84e27d to your computer and use it in GitHub Desktop.
Using Spread Operator in objects and arrays.
let arr1 = ['apple', 'banana'];
let arr2 = [...arr1, 'watermelon'];
console.log(arr1);
console.log(arr2);
let obj1 = {
name: 'Bruno',
surname: 'Krebs'
}
let obj2 = {
...obj1,
country: 'Brazil'
}
console.log(obj1);
console.log(obj2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment