Created
July 10, 2020 12:48
-
-
Save rishisidhu/2856c479eb2e4beb7748dc0f0eb25e86 to your computer and use it in GitHub Desktop.
Modern JS ES6+ features - Spread Operator
This file contains 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
array1 = [1, 2, 3, 5]; | |
object1 = { | |
key1: "value1", | |
key2: "value2", | |
}; | |
//Spread operator in array | |
array2 = [10, ...array1]; | |
console.log(array2); | |
//Spread operator in object | |
object2 = { | |
key3: "value3", | |
...object1, | |
}; | |
console.log(object2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment