Created
December 28, 2017 17:02
-
-
Save brunokrebs/71e8fba79a312413c9f5ecac7f84e27d to your computer and use it in GitHub Desktop.
Using Spread Operator in objects and arrays.
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 characters
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