spread operator and rest operator code example
Example 1: array spread operator in javascript
let arr1 = ['A', 'B', 'C'];
let arr2 = ['X', 'Y', 'Z'];
let result = [...arr1, ...arr2];
console.log(result);
Example 2: spread and rest operator javascript
var myName = ["Marina" , "Magdy" , "Shafiq"] ;const [firstName , ...familyName] = myName ;console.log(firstName);
Example 3: spread operator javascript
[a, b, ...objIteravel] = [1, 2, 3, 4, 5];
Example 4: spread and rest operator javascript
function myData(...args){console.log(args) ;