#author("2020-06-10T18:33:04+09:00","default:ryuichi","ryuichi")
#author("2020-06-10T18:33:19+09:00","default:ryuichi","ryuichi")
* 配列の中の値がユニークか調べる [#nb36725e]

 const array1 = [1,2,3,1];
 if (([...new Set(array1)]).length == array1.length) {
     console.log("unique");
 } else {
     console.log("not unique");
 }
 
 => not unique

 => not unique
 const array2 = [1,2,3];
 if (([...new Set(array2)]).length == array2.length) {
     console.log("unique");
 } else {
     console.log("not unique");
 }
 
 => unique

** 参考 [#f5ee2e72]

https://stackoverflow.com/questions/9229645/remove-duplicate-values-from-js-array/9229821#9229821

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS