Build an array with string index
You are trying to set the key of objects within an array, instead of creating an object with keys,
i.e instead of
let arr2 = []
arr.forEach((item) => {
arr2[item.barcode] = item
})
you would want:
let obj2 = {}
arr.forEach((item) => {
obj2[item.barcode] = item
})