JSFiddle - React, Tailwind, and code Playground

by realhunts

JavaScript

let response = [{
  x: 1,
  y: 2
}, {
  x: 1,
  y: 2
}, {
  x: 3,
  y: 2
}]

let o = response.reduce((acc, cv) => {
  if (!acc[JSON.stringify(cv)]) {
    acc[JSON.stringify(cv)] = true; //something non-falsy
  }
  return acc;
}, {});

let res = Object.keys(o).map(x => JSON.parse(x));
console.log(res);