join() and toString() methods are used to convert our arrays to a string.
Array.Join(“ , ”) //Strawberry-Cookies , Stick-Sweets , Lollipop , Kolas , Vanilla
Let Cookies = [“Strawberry-Cookies”, “Stick-Sweets”, “Lollipop”, “Kolas”, “Pinky”] Console.Log(Cookies) Cookies.Pop() Console.Log(Cookies) Cookies.Push(‘Vanilla’) Console.Log(Cookies)
But, in order to change that structure, and remove elements from the first index we make use of the shift() method. Shifting and popping works the same way only that, shift works on the first element instead of the last.
Also with unshift() method we push elements to the first index of the array.
splice() method can be used to add new element in the array and if perfectly formatted, splice method can be used to remove elements from an array.
Splice (Start, DelCount, Opt)
start: defines the position where new elements should be added (spliced in).
delCount: defines how many elements should be removed
opt: optionally, defines the elements to be added
With concat() method we can merge two arrays together to generate a new separate array.
Let Minerals = [“Coca-Cola”, “Sprites”]; Let Lemon = [“Lemonade”]; Let SoftDrinks = Minerals.Concat(Lemon);
The slice() method slices out a piece of an array into a new array.
Let Colors = [“Blue”, “Orange”, “Green”]; Let SlicedColor = Colors.Slice(1);
The sort() method is used to sort the elements in the arrays