Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find only duplicate data javascript object


export const findDuplicate = (data: Record<string, any>[]): number[] => {
	const duplicates: number[] = data
		.filter((item: Record<string, any>, index: number) => index !== data.findIndex((v: Record<string, any>) => v.order_id === item.order_id))
		.map((val: Record<string, any>) => val.id)

	return duplicates
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #duplicate #data #javascript #object
ADD COMMENT
Topic
Name
6+4 =