LoginSignup
13
12

More than 5 years have passed since last update.

配列の重複の有無をチェック(es2015 ver)

Posted at

const isDup = (arr) => arr.length !== new Set(arr).size
isDup([1,2,3,4,5]) // false
isDup([1,1,2,3,4]) // true
isDup(new Array(5))// true. [undefined, undefined,...] のため

なお、[...new Set(array)] とやれば、重複のない配列が作れる

You Might Not Need Underscore

13
12
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
13
12