Rhapsodist
2020.03.03
Created By Rhapsodist
Rhapsodist

Array ( 배열 )에서 unique 값, 즉 똑같은 값이 없는 상태로 바꿀 수 있는 방법에는 여러가지가 있다. es6 문법에서는 간단히 함수 하나로 가능 하게 되었다.
console.log(uniqueArray([1, 2, 3, 1, 5, 6, 8]))
function uniqueArray(array) {
const result = Array.from(new Set(array));
return result
}
// => [1, 2, 3, 5, 6, 8]Set 에 기존 array 를 넣어주고, 리턴값을 다시 array로 반환 시켜주면 위와 같이 unique한 값을 얻을 수 있다.
© 2020, made by Rhapsodist