1/**
2* JS Spread and Rest operators:
3* Two operators with the same syntax (...) but behave differently
4*/
5
6// Rest parameter: collects all remaining elements into an array.
7function foo (...args) { console.log(args) }
8foo(1,2,3,4,5,6) // Output: (6) [1,2,3,4,5,6]
9
10// Spread operator: allows iterables to be expanded into single elements.
11let arr = [1, 2, 3];
12let arrCopy = [-1, 0, ...arr]; // spread the array into a list of parameters
13 // then put the result into a new array
1function myData(...args){console.log(args) ; // ["Marina",24,"Front-End Developer"]}myData("Marina",24,"Front-End Developer") ;