1var myName = ["Marina" , "Magdy" , "Shafiq"];var newArr = [...myName ,"FrontEnd" , 24];console.log(newArr) ; // ["Marina" , "Magdy" , "Shafiq" , "FrontEnd" , 24 ] ;
1var myName = ["Marina" , "Magdy" , "Shafiq"] ;const [firstName , ...familyName] = myName ;console.log(firstName); // Marina ;console.log(familyName); // [ "Magdy" , "Shafiq"] ;
1function sum(...numbers) {
2 return numbers.reduce((accumulator, current) => {
3 return accumulator += current;
4 });
5};
6
7sum(1,2) // 3
8sum(1,2,3,4,5) // 15
1function sum(x, y, z) {
2 return x + y + z;
3}
4
5const numbers = [1, 2, 3];
6
7console.log(sum(...numbers));
8// expected output: 6
9
10console.log(sum.apply(null, numbers));
11// expected output: 6
1function myData(...args){console.log(args) ; // ["Marina",24,"Front-End Developer"]}myData("Marina",24,"Front-End Developer") ;