LoginSignup
1
1

More than 3 years have passed since last update.

配列の重複削除(バニラJS)

Posted at

生JavaScriptを使って配列から重複を削除する

qiita.rb
var fruits  = ['りんご', 'バナナ', 'りんご', 'バナナ', 'パイナップル', 'スイカ', 'りんご', 'バナナ'];
var deduped = Array.from(new Set(fruits));

console.log(deduped);  // -> ["りんご", "バナナ", "パイナップル", "スイカ"]

引用元
https://gomakethings.com/removing-duplicates-from-an-array-with-the-vanilla-js-set-object/

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