LoginSignup
0
0

JavaScriptのconcatを利用する

Posted at

はじめに

表題通り、JavaScriptのconcatを利用します。

sample.js
const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = array1.concat(array2);

console.log(array1);
console.log(array2);
console.log(array3);
// Expected output: Array ["a", "b", "c", "d", "e", "f"]

image.png

concat() は Array インスタンスのメソッドで、2 つ以上の配列を結合するために使用します。 このメソッドは既存の配列を変更せず、新しい配列を返します。

なるほど。ちょっと勉強になりました。

0
0
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
0
0