为什么NodeJS / Javascript坚持这些变量是未定义的?

时间:2018-04-15 16:28:36

标签: javascript node.js undefined

我现在正在努力解决这个问题大约一个小时,这是违法的代码:

const t = games[0];
for (const mvar in t) {
    if (t.hasOwnProperty(mvar))
        console.log(`${mvar}: ${t.mvar}`);
}

输出结果为:

appid: undefined
name: undefined
playtime_forever: undefined
img_icon_url: undefined
img_logo_url: undefined
has_community_visible_stats: undefined

但是,WebStorm调试器表示此值未定义为: enter image description here

还有其他原因可以吗?

1 个答案:

答案 0 :(得分:8)

t没有名为myVar的属性。

您希望t[myVar]获取具有该名称的媒体资源。

相关问题