Как добавить ID в массив JavaScript
let data = [{
color: "red",
value: "#f00"
}, {
color: "green",
value: "#0f0"
}, {
color: "blue",
value: "#00f"
}, {
color: "cyan",
value: "#0ff"
}, {
color: "magenta",
value: "#f0f"
}, {
color: "green",
value: "#ff0"
}, {
color: "black",
value: "#000"
}];
data.forEach((o, i) => o.id = i + 1);
console.log(data);
Blue Bee