Hi Friends 👋,
Welcome To Infinitbility! ❤️
concat() method to merge two arrays.
The concat() method is used to merge two or more arrays. This method does not change the existing arrays but instead returns a new array.
So, here we will create two sample arrays like the below example, after that, we will use
concat() method to append one array to another, and store it in the third array variable.
1// create sample arrays2const arr1 = ['a', 'b', 'c'];3const arr2 = ['d', 'e', 'f'];45// apend array6const arr3 = arr1.concat(arr2);78console.log(arr3);
when you run the above code, it will concat both array and print in your console.
let’s check the output.
I hope it’s help you, All the best 👍.
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.