const lunchMenuIdeas = ['Harvest Salad', 'Southern Fried Chicken'];
const allMenuIdeas = [...lunchMenuIdeas];
allMenuIdeas.push('Club Sandwich');
console.log(allMenuIdeas);
using square brackets and ... prevents the lunchMenuIdeas array from being overwritten by allMenuIdeas as arrays are passes as references
Top comments (0)