Suppose that I have an object like this (it's a chart js setting).
const radarChartData = {
labels: [3, 4, 6, 7, 8, 8],
data: [0, 0, 0, 0, 0, 0],
bgArr: this.labels.map((label, i) => label === 10 ? "red" : "blue"); // An error has occurred, because this code can't access its own labels in radarChartData.
datasets: [{.....}]
}
const radarChartConfig = {
type: ....,
}
const radarChart = new Chart(radarChartCtx, radarChartConfig)
I tried the following fix, but all failed...
bgArr: radarChartData.labels.map((label, i) => label === 10 ? "red" : "blue");
How to access its own property? In the first place, it's not a good option to access it and this way?