gpt4 book ai didi

javascript - 对象值未定义

转载 作者:搜寻专家 更新时间:2023-11-01 00:26:17 25 4
gpt4 key购买 nike

我无法以稍后可以调用的方式定义值。

如果我先定义 Search,那么 Search.commands[3] 是未定义的。如果我先定义 commandList,那么 commandList.commands[0] 是未定义的。

有没有更好的方法来定义这些对象,使得顺序无关紧要?

var Search = {
'str': 'search',
'param': 'search',
'action': '',
'commands': [
Category,
Location,
Sort,
commandList
]
}

var commandList = {
'commands': [
Search,
Category,
Stop
]
}

最佳答案

var Search = {
'str': 'search',
'param': 'search',
'action': ''
};
var commandList = {
'commands': [
Search,
Category,
Stop
]
};
Search.commands = [
Category,
Location,
Sort,
commandList
];

关于javascript - 对象值未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14616122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com