기술공부/언어
[JavaScript] Array 중복 제거
봉두두
2023. 2. 21. 15:32
728x90
var thisResult = result;
result = thisResult.filter(function(item1, idx1){
return thisResult.findIndex(function(item2, idx2){
return item1['중복attribute'] === item2['중복attribute']
}) == idx1
});
Array.filter 속성을 활용하면
Array 내에서 특정 attribute에 대한 중복값을 제거할 수 있게 된다.
아래는 테스트 화면
728x90
728x90