0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JS 2つ配列を結合し、重複を削除する方法

Last updated at Posted at 2024-12-17

2パターンあります
2つの配列変数array1,array2を展開、重複削除、配列にまとめ直しを行います

①concatで配列を結合、new Setで重複削除、...スプレッド構文でまとめ直し

const combinedStores = [...new Set(array1.concat(array2))];

②...スプレッド構文と[]で配列を展開結合、new Setで重複削除、Array.fromでまとめ直し

const combinedStores = Array.from(new Set([...array1, ...array2]));
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?