The second function that we are going to take a look at today is called concat. And what concat does is that it adds more elements, it adds to arrays to each other's and in stored them in a new array. So suppose that I want to add more elements here to this to this day's array, or I want to create a new array. What I'm going to do is just I'm going to use the days and then I'm going to call concat. And then here I'm going to pass a new array called maybe Thursday, Thursday, if I store the result here, in a new array called new array, new array, and pass and I pass this new array here. Save and Run, which I'm going to get.
As you can see, Thursday has been concatenated. And a new array has been emerged. So if I have an array, and I want to add more elements at the end only at the end, I would just pass a new array here. So it's less useful than the splice method because you cannot add a specific element or specific array in between or even delete. So it just combines two arrays, mix them into one new array. The third function that we are going to take a look at is called join.
And what join does is that it adds a specific character in between elements in an array and returns the result as a string. So let's try this function. Here. Suppose that I have this array again days and a want to just add space in between them and return them as a big string. What I'm going to do is that I'm going to use again this array, and then I'm going to call this join. And inside the join, what I'm going to do is just I'm going to pass it with a one to separate or add in between each of these elements.
So what I'm going to add is just an empty string. So the result is inside a new array, called days a one. Now, if I save and run, what I'm going to get is that Saturday, Monday, Tuesday and Wednesday, and they are just a string. Now it's this one is a string, but the here we have just added a space. And suppose that you you don't want to add space you want to add, let's say coma, just add comma here and say run. And what I'm going to get is Saturday, Monday, Tuesday, and Wednesday and a bit in between each element, just a comma.
So what join does is that it adds an element or a character in between elements of an array and returns the result. A string, another function called slice. And what slice does is that it takes a copy of this array or part of it and stores it into a new array. So let's try this function. Here, I'm going to create a new variable or array called Data one. And I'm going to store the result of this, I'm going to use the days that slice this time.
And what slice function does it takes what slice function takes as parameters, it takes two parameters. The first one is the parameter that you want to start at copying. And the second parameter is the parameter in which you want to end but it's not included. So So suppose that they want to copy only Saturday and Monday. What I'm going to do is that I'm going to add the starting position or index which is zero and the ending position is good. Going to be not one, it's going to be two because two is not is not going to be included.
If I add one, one is not going to be included, therefore I want I have to increase it by one. So here I'm going to pass two instead of one. And what that means is that I'm going to copy position one, position zero, as well as one, but two is not going to be included. So here the in the position is not going to be included. So let's now save and run. And as you can see, I get a new copy, I get a copy of this array, or actually part of it, only the first and second parameter.
But if I pass instead of two, one, what what I'm going to get is I'm going to get only Saturday because as I told you, the ending position is not included. So I end at position one, but it's not going to be included. So these are very important functions for arrays and will make everything easier to use. Later later when you work with arrays, so I would suggest practicing these functions a lot with many, many examples, because you will have to use them later and instead of creating your own functions to do a specific task for arrays, you have already these functions that will get the job done for you.