1let array = ["Chicago", "Los Angeles", "Calgary", "Seattle", ]
2 // print the array
3console.log(array)
4 //Adding a new item in an array without touching the actual array
5array.push('New Item') < variable_name > .push( < What you want to add > )
6 //How many items does the array have?
7console.log("This array has", array.length, "things in it")
1
2let chocholates = ['Mars', 'BarOne', 'Tex'];
3let chips = ['Doritos', 'Lays', 'Simba'];
4let sweets = ['JellyTots'];
5
6let snacks = [];
7snacks.concat(chocholates);
8// snacks will now be ['Mars', 'BarOne', 'Tex']
9// Similarly if we left the snacks array empty and used the following
10snacks.concat(chocolates, chips, sweets);
11//This would return the snacks array with all other arrays combined together
12// ['Mars', 'BarOne', 'Tex', 'Doritos', 'Lays', 'Simba', 'JellyTots']
13
1const arr1 = [1,2,3]
2const newValue = 4
3const newData = [...arr1, obj] // [1,2,3,4]