const shortCode = {
DA: ['934', '986', '879'],
BA: ['914', '926', '849'],
AD: ['911', '900', '899']
};
如何在该短代码对象上获取密钥。假设我有“ 879”值并搜索对应的密钥?
用Java语言编写。
最佳答案
您可以在find
的Object.keys
上使用shortCode
:
const shortCode = {
DA: ['934', '986', '879'],
BA: ['914', '926', '849'],
AD: ['911', '900', '899']
};
const res = Object.keys(shortCode)
.find(k => shortCode[k].includes('879'));
console.log(res);
关于javascript - 如何在javascript对象上找到键,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53423736/