let arr = [1, 2, "test", "bob", false, 33]; /* Let's say we initialized array with some data in it. Now we want to add some data. There are methods like unshift(), push(), splice */ arr.unshift("new data"); console.log(arr); //Output: ["new data", 1, 2, "test", "bob", false, 33] /* unshift() method adds new data to the first position You can add more than one element, by seperating elements with a comma */ arr.unshift("new data", 2333); console.log(arr); //Output: ["new data", 2333, 1, 2, "test", "bob", false, 33] arr.push("some data"); console.log(arr); //Output: [1, 2, "test", "bob", false, 33, "some data"] /* push() is same as unshift() except it adds data to the end of an array. You can also add multiple elements by seperating them with a comma */ arr.push("some data", "more data"); console.log(arr); //Output: [1, 2, "test", "bob", false, 33, "some data", "more data"]; arr.splice(2, 0, "Here is new data", "This is another one", 100); console.log(arr); //Output: [1, 2, "Here is new data", "This is another one", 100, "test", "bob", false, 33]; /* By using splice() method you can add multiple elements where ever you want inside your array. First parameter inside splice, in our case it was number 2, is on what position do you start to add elements, 0 means you do not want to remove any elements, and at the end you specify what elements, as many as you want, comma separated. */