This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
In this article, you will learn how to concatenate arrays in Javascript.
Let’s say you have two arrays and you want to combine them into a single array.
var arr1 = ["I", "love"];
var arr2 = ["codesource.io", "very", "much"];
In order to concatenate arrays, you can use the concat()
method.
var arr1 = ["I", "love"];
var arr2 = ["codesource.io", "very", "much"];
console.log(arr1.concat(arr2));
Note: The concat()
method functions by joining two or more arrays together.
The post How to Concatenate Arrays in Javascript appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
Ariessa Norramli | Sciencx (2021-02-17T12:02:47+00:00) How to Concatenate Arrays in Javascript. Retrieved from https://www.scien.cx/2021/02/17/how-to-concatenate-arrays-in-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.