Join two arrays:
const arr1 = ["Cecilie", "Lone"];
const arr2 = ["Emil", "Tobias", "Linus"];
const children = arr1.concat(arr2);
Join three arrays:
const arr1 = ["Cecilie", "Lone"];
const arr2 = ["Emil", "Tobias", "Linus"];
const arr3 = ["Robin"];
const children = arr1.concat(arr2, arr3);
More examples below.
DescriptionThe concat()
method concatenates (joins) two or more arrays.
The concat()
method returns a new array, containing the joined arrays.
The concat()
method does not change the existing arrays.
array1.concat(array2, array3, ..., arrayX)
Parameters Parameter Description array1,... Required.Concatenate strings and numbers:
const arr1 = ["Cecilie", "Lone"];
const arr2 = [1, 2, 3];
const arr3 = arr1.concat(arr2);
Concatenate nested arrays:
const arr1 = [1, 2, [3, 4]];
const arr2 = [[5, 6], 7, 8];
const arr3 = arr1.concat(arr2);
concat()
is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
Chrome Edge Firefox Safari Opera IE Yes Yes Yes Yes Yes YesTrack your progress - it's free!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4