Skip to content

Instantly share code, notes, and snippets.

@mojaray2k
Last active April 24, 2020 05:52
Show Gist options
  • Save mojaray2k/a7468299b091f1a126883c01904edc7a to your computer and use it in GitHub Desktop.
Save mojaray2k/a7468299b091f1a126883c01904edc7a to your computer and use it in GitHub Desktop.
Array Concat Method

Definition and Usage

The concat method is used to join two or more arrays. This method does not change the existing arrays, but returns a new array, containing the values of the joined arrays.

// join two arrays
var hege = ["Cecilie", "Lone"];
var stale = ["Emil", "Tobias", "Linus"];
var children = hege.concat(stale);

console.log(children)

// join three arrays
var hege = ["Cecilie", "Lone"];
var stale = ["Emil", "Tobias", "Linus"];
var kai = ["Robin"];
var children = hege.concat(stale, kai);

console.log(children)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment