Which fix removes the subtle bug?
const ids = rows.map((r) => r.id); const uniq = ids.filter((id, i) => ids.indexOf(id) === i); const missing = uniq.filter((id) => !id);
- Test with
id == nullso 0 is kept - Test with
id === nullso 0 is kept - Change
uniq.filtertouniq.every - Compare
indexOf(id) !== iinstead
!id also matches the valid id 0 and an empty string; test for null/undefined explicitly.