- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-06-10T18:33:04+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
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