![](/img/trans.png)
[英]Javascript - how to create an array of objects where the object's keys all have the same value
[英]how extract an object from an array where all of the keys are the same
我已經堅持了一段時間。 我有一個 object 數組,其中所有對象的鍵都是相同的(見下文)。 我正在嘗試從數組 [0] 中的第一個 object 中提取數據。 但是,當我 console.log 數據時,我得到未定義的“無法讀取屬性 '0”。 這是我剛剛過濾數據時收到的數據圖像。
這是我用來獲取該數據的代碼:
const handleClick = e => {
e.preventDefault();
const buttonValue = e.target.value;
console.log(buttonValue);
grid.on('rowClick', (...args) =>
args.filter(data => {
data.cells;
console.log(data.cells);
})
);
};
當我將索引 0 添加到 console.log console.log(data.cells[0]);
我得到未定義的無法讀取屬性 0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.