spread operator add to array code example
Example 1: spread operator in javascript
let numList = [1,2,3];
let numListClone = [...numList];
let animal = {
name: 'dog',
color: 'brown',
age: 7
};
let { age, ...otherProperties } = animal;
function sum(x, y, ...rest) {}
let numLists = [...numList1, ...numList2];
let animalWithBreed = {
...animal,
breed: '',
}
Example 2: addition in spread operator in javascript
let numberStore = [0, 1, 2];
let newNumber = 12;
numberStore = [...numberStore, newNumber];
Example 3: spread operator javascript
const parts = ['shoulders', 'knees'];
const lyrics = ['head', ...parts, 'and', 'toes'];
Example 4: spread operator es6
[...fruits]