LoginSignup
2
3

More than 5 years have passed since last update.

配列のマージ

Posted at

メモ


var array1 = [1, 2, 3];
var array2 = [4, 5, 6];


//結合
var newArray = array1.concat(array2);

console.log(newArray);
=>[1, 2, 3, 4, 5, 6]

console.log(array1);
=>[1, 2, 3]


//破壊的結合
var ArrayLength = Array.prototype.push.apply(array1, array2);

console.log(ArrayLength)
=> 6

console.log(array1);
=> [1, 2, 3, 4, 5, 6]


2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3