1obj = {first_name : "Marty",
2 lovers: ["Jennifer Parker","Baines McFly"]
3 };
4let objClone = { ...obj }; // pass all key:value pairs from an object
5
6console.log(objClone)
7// { first_name: "Marty", lovers: ["Jennifer Parker", "Baines McFly"] }
1var num = [2, 4, 6, 8, 10];
2console.log(...num)
3//expected output: 2 4 6 8 10
4console.log(88, ...num, 99)
5// added extra new elements before and after the spread operator
6//expected output: 88 2 4 6 8 10 99
1var num = [2, 4, 6, 8, 10];
2console.log(...num)
3//expected output: 2 4 6 8 10
4console.log(88, ...num, 99)
5//expected output: 88 2 4 6 8 10 99
1let obj1 = { foo: 'bar', x: 42 };
2let obj2 = { foo: 'baz', y: 13 };
3
4let clonedObj = { ...obj1 };
5// Object { foo: "bar", x: 42 }
6
7let mergedObj = { ...obj1, ...obj2 };
8// Object { foo: "baz", x: 42, y: 13 }
1function myFunction(v, w, x, y, z) { }
2let args = [0, 1];
3myFunction(-1, ...args, 2, ...[3]);
1let numberStore = [0, 1, 2];
2let newNumber = 12;
3numberStore = [...numberStore, newNumber];
4hhh
5