728x90

✨ 유일한(unique)값을 얻고 싶을 때 사용할 수 있는 Built-in Object

💻Example Code

const strArr = ['a', 'a', 'b', 'b', 'cde', 'cde'];
const uniqueValues = new Set(strArr);
console.log(uniqueValues);
console.log(Array.from(uniqueValues));
view raw setObject.js hosted with ❤ by GitHub

실행 결과

🧨 중복된 값이 여러 개 존재할 때 유용하게 사용 가능하다.

👉 자세한 내용https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set

'JavaScript > Built-in Method etc.' 카테고리의 다른 글

Array.prototype.splice()  (2) 2020.05.15
String.prototype.charAt()  (0) 2020.02.22
String.prototype.localeCompare()  (0) 2020.02.20
Math.round()  (0) 2020.02.16
Math.abs()  (0) 2020.01.28

+ Recent posts