Array Concat in JavaScript

Level 261 keystrokes

concat() merges two or more arrays into a new array without modifying the originals.

JavaScript code

// Create first array
1const a = [1, 2];
// Create second array
2const b = [3, 4];
// concat() combines arrays into a new array [1, 2, 3, 4]
3console.log(a.concat(b));

Output

[ 1, 2, 3, 4 ]
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • ;× 3
  • ,× 2
  • .× 2
  • (× 2
  • )× 2
  • [× 2
  • ]× 2
  • =× 2

More JavaScript examples at level 2

← JavaScript typing practice