JSFiddle - React, Tailwind, and code Playground

by amrendra kumar

JavaScript

const arr = [
  {
    name: 'abcd122',
    macId: 'abc111',
    type: 'cluster',
    clusterId: '5a687fcc6ba7345fddcec418',
    coordinates: { x: 1, y: 1, z: 1 },
    plotCoordinates: { x: 1, y: 1, z: 1 }
  },
  {
    name: 'abcd123',
    macId: 'abc222',
    type: 'cluster',
    clusterId: '5a687fcc6ba7345fddcec418',
    coordinates: { x: 1, y: 1, z: 1 },
    plotCoordinates: { x: 1, y: 1, z: 1 }
  },
  {
    name: 'abcd121',
    macId: 'abc333',
    type: 'cluster',
    clusterId: '5a687fcc6ba7345fddcec418',
    coordinates: { x: 1, y: 1, z: 1 },
    plotCoordinates: { x: 1, y: 1, z: 1 }
  },
  {
    name: 'abcd121',
    macId: 'abc444',
    type: 'cluster',
    clusterId: '5a687fcc6ba7345fddcec418',
    coordinates: { x: 1, y: 1, z: 1 },
    plotCoordinates: { x: 1, y: 1, z: 1 }
  }
]

const r = arr.filter((d,index, arr) =>index === arr.findIndex(obj => obj.name === d.name) )

console.log(r)