A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.w3schools.com/jsref/jsref_concat_array.asp below:

Website Navigation


JavaScript Array concat() Method

JavaScript Array concat() Examples

Join two arrays:

const arr1 = ["Cecilie", "Lone"];
const arr2 = ["Emil", "Tobias", "Linus"];
const children = arr1.concat(arr2);

Try it Yourself »

Join three arrays:

const arr1 = ["Cecilie", "Lone"];
const arr2 = ["Emil", "Tobias", "Linus"];
const arr3 = ["Robin"];
const children = arr1.concat(arr2, arr3);

Try it Yourself »

More examples below.

Description

The 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.

Syntax

array1.concat(array2, array3, ..., arrayX)

Parameters Parameter Description array1,... Required.
The array(s) to be concatenated. Return Value Type Description Array The content from the joined arrays. More Examples

Concatenate strings and numbers:

const arr1 = ["Cecilie", "Lone"];
const arr2 = [1, 2, 3];
const arr3 = arr1.concat(arr2);

Try it Yourself »

Concatenate nested arrays:

const arr1 = [1, 2, [3, 4]];
const arr2 = [[5, 6], 7, 8];
const arr3 = arr1.concat(arr2);

Try it Yourself » Browser Support

concat() is an ECMAScript1 (JavaScript 1997) feature.

It is supported in all browsers:

Chrome Edge Firefox Safari Opera IE Yes Yes Yes Yes Yes Yes

Track 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