Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find only duplicate data javascript object

const data = [{id: 1, order_id: 1}, {id: 2, order_id: 1}, {id: 3, order_id: 2}]
const duplicates = data.filter((item, index) => 
index !== data.findIndex((v) => v.order_id === item.order_id));

console.log(duplicates)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #duplicate #data #javascript #object
ADD COMMENT
Topic
Name
7+9 =