I was looking at someone else's code on Stack Overflow (this answer) and saw something weird. Something I've never seen before. Also, I could not find any documentation.
This code (based on the code in the answer) is an example:
let data = [
{ records: "productId*amount*tax1*tax2*tax3", id: 467 },
{ records: "111*2000*10*12*13", id: 278 },
{ records: "113*3000*10**", id: 787 }
];
let ids = data.map(({ id }) => console.log(id));
So apparently, when you use ({id})
as an argument for the callback, the argument does not contain the item in the array, but the value of that property of the item (object) in the array.
Anybody know what's going on here?