concat Array Method | JavaScript Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
the array concat method allows you to merge two or more arrays into one new array which will be retired you can see in our example we have a and B which are both an array and if we want to create a new array for example C we can do a dot concat B and now if we consult that logging C you can see in the right we get one two three four five and six which are all the elements inside the two arrays let's say you want to add one more array in this new array we're creating for example D it can be seven eight nine pass it in as parameter for the Coquette method and now the new array will be one two three four five six seven eight nine the good thing with the concat method is that it won't change the array which are used in our example a b and d so if you consult that log a and then B and D here you can see that the arrays remain unchanged this is very useful when you're working for example inside the function and you want to take in an array as a parameter but you don't want to change that array you'll create a new copy of that array and then you'll manipulate the new array if you don't pass anything for the concat method as a parameter you will get a shallow copy of the a array basically is the same array as a but it's a copy of it now before changing C for example we're pushing something for constant that Loxy you can see that C is one two three four but a will remain the same one two three four and this is a one two and three basically this will create a shallow copy of the array let's clear the console and we can also use the concat method as a push method if we're adding here numbers as parameters we can consider that Loxy now and it will be one two three one two so it will work as a push method the only difference is that if you're adding an array inside it will be appended at the end here we're creating a which is one two three we're adding one two and then we're appending a again one two three I hope you enjoyed this tutorial and I'll see you in the next one bye [Music]
Info
Channel: Florin Pop
Views: 4,766
Rating: 4.973856 out of 5
Keywords: javascript, javascript tutorial, javascript tutorial for beginners, array method, javascript arrays, learn javascript, javascript array methods, concat, javascript concat, concat array method, learn concat
Id: PHgeshcXtDc
Channel Id: undefined
Length: 2min 49sec (169 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.