我有一个对象:
messages = {
V1: {
summary: "summary one",
cause: "cause one",
code: "1"},
V2: {
summary: "summary two",
cause: "cause two,
code: "2"
}我想将event.details的值与对象消息的键进行比较,并为匹配键的摘要,原因和代码设置变量。
到目前为止我的实施:
if (event.details === Object.keys(messages)) {
var a = the summary of the matching key;
var b = the cause of the matching key;
var c = the code for the matching key;};后来我在我的代码中使用了这些变量....目前我的结果是:
event.details = "V1"Object.Keys(messages) = ["V1","V2"]
但这只是给了我一系列的钥匙。我想现在获取匹配键的信息。
如何查看密钥是否与event.details相匹配?以及如何将变量设置为密钥的摘要,原因和代码?
绝地无双
holdtom
慕森卡
随时随地看视频慕课网APP
相关分类