let array1 = ["one", "two", "three", "four"]
let array2 = ["five", "six", "seven"]
// Spread operator
let finalArray = [...array1, ...array2]
console.log(finalArray)
// output: ["one", "two", "three", "four", "five", "six", "seven"]
// rest operator
let [first, ...rest] = array1
console.log(first) //output: one
console.log(rest) // output: ["two", "three", "four"]
var myName = ["Marina" , "Magdy" , "Shafiq"];var newArr = [...myName ,"FrontEnd" , 24];console.log(newArr) ; // ["Marina" , "Magdy" , "Shafiq" , "FrontEnd" , 24 ] ;
var myName = ["Marina" , "Magdy" , "Shafiq"] ;const [firstName , ...familyName] = myName ;console.log(firstName); // Marina ;console.log(familyName); // [ "Magdy" , "Shafiq"] ;
var array = ['red', 'blue', 'green']
var copyOfArray = [...array]
console.log('Copy of', array, 'is', copyOfArray)
console.log('Are', array, 'and', copyOfArray, 'same?', array === copyOfArray)