Skip to content

Instantly share code, notes, and snippets.

@rishisidhu
Created July 10, 2020 12:48
Show Gist options
  • Save rishisidhu/2856c479eb2e4beb7748dc0f0eb25e86 to your computer and use it in GitHub Desktop.
Save rishisidhu/2856c479eb2e4beb7748dc0f0eb25e86 to your computer and use it in GitHub Desktop.
Modern JS ES6+ features - Spread Operator
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