-2

I'm trying to compare 2 objects by their values not by their reference, hence strict & loose equality oparator aren't useful.

EXP:

let cars = [{
    "color": "purple",
    "type": "minivan",
    "registration": new Date('2017-01-03'),
    "capacity": 7
  },
  {
    "color": "red",
    "type": "station wagon",
    "registration": new Date('2018-03-03'),
    "capacity": 5
  },

]
this.model = cars.map(function(el) {
  const o = Object.assign({}, el);
  const keys1 = Object.keys(this.model[0]);
  const keys2 = Object.keys(el);
  console.log("CHECK ", keys2 == keys1);
  return o;
});
Barmar
  • 741,623
  • 53
  • 500
  • 612
hai wayl
  • 1
  • 2
  • You have to define what "equal" means in your application, and then write some code to implement that comparison. – Pointy Sep 01 '23 at 23:25

0 Answers0