so-63913966

https://stackoverflow.com/questions/63913966/change-the-value-of-every-object-in-an-array-if-0-to-null

by lorrylockie

JavaScript

const sample = [
  { id: 1, val1: 0, val4: 10 },
  { id: 10, val1: 1, val4: 10, val19: 0, val29: 0 },
  { id: 11, val1: 0, val4: 0, val19: 0, val29: 10 },
];

sample.map((s) => {
  for (let i in s) if (s[i] === 0) s[i] = null;
  return s;
});
console.log(sample);