在对象中使用变量作为标识符

Using variable as identifier in object

我有这样的代码:

for (var i = 0; i < result.Table.length; i++) {
    for (var x = 0; x < count; x++) {                           
        var xIndex = 'F' + (x + 1)
        var item = result.Table[i].xIndex;
        console.log(item)
    }
}

但不幸的是,我不能像这样在示例中使用 xIndex。那么如何更改脚本才能将 xIndex 设置为标识符?

谢谢。

你不能在那里使用点语法,只需使用方括号就可以了

result.Table[i][xIndex]