티스토리 뷰
728x90
JSON에서 원하는 값을 parsing 한 후에 중복 값 제거하기
const myArray = [
{ "id" : "1", "name" : "sskim", "country" : "korea" },
{ "id" : "2", "name" : "lsy", "country" : "usa" },
{ "id" : "3", "name" : "lsw", "country" : "canada" },
{ "id" : "1", "name" : "sskim", "country" : "korea" },
{ "id" : "5", "name" : "nyw", "country" : "australia" },
{ "id" : "5", "name" : "kjh", "country" : "italia" }
];
const unique = myArray.map(function (val, index) {
return val['id'];
}).filter(function (val, index, arr) {
return arr.indexOf(val) === index;
});
console.log(unique);
728x90
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- intellij
- 오라클
- 북리뷰
- mybatis config
- maven
- LocalDate
- mybatis
- docker
- JavaScript
- config-location
- Bash tab
- LocalDateTime
- svn
- Github Status
- jQuery
- input
- Mac
- elasticsearch
- 베리 심플
- springboot
- Linux
- Spring
- oracle
- rocky
- localtime
- Kotlin
- window
- k8s
- Spring Security
- Java
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함