join Array Method | JavaScript Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
the array join method creates a new string from an array by concatenating all the elements from that array by default it uses a comma as a separator but you can specify what separator you want to be added between the items let's see how this looks in code we're going to store the result in a res variable and we can say countries that join and now if you console that lock res you can see here in the right that we have Romania USA and India separated by the comma which is the default separator but you can specify what separator you want maybe one two - between and two spaces you can have that or maybe you want a comma but also space you can do that also or maybe you don't want any separator so you can just put in an empty string and then they will be concatenated like that just keep in mind that the separator will be added between the elements and if for example we only have one element and we use a separator that separator won't be used because we only have one element so it doesn't need to separate the elements with something this method is useful when you want to create something like let's revert back to what we had and put the comma and space and you want to say something like I want to visit that and you add in the response the result we have there and there we go I want to visit Romania USA in India and now you can easily add something else maybe UK and it will say oops I forgot the comma save and it will say I want to visit Romania u.s. India UK alright I hope you enjoyed this tutorial and I see you in the next one I [Music]
Info
Channel: Florin Pop
Views: 4,912
Rating: 4.9774013 out of 5
Keywords: javascript, javascript tutorial, javascript tutorial for beginners, array method, javascript arrays, learn javascript, javascript array methods, map, JavaScript map, map array method, learn map, join, javascript join, join array method, learn join, join an array into a string, string separator
Id: 1a2OCwBD-yI
Channel Id: undefined
Length: 2min 20sec (140 seconds)
Published: Thu Apr 02 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.