第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用javascript獲取具有多個(gè)鍵和值對(duì)的對(duì)象中的值的鍵

使用javascript獲取具有多個(gè)鍵和值對(duì)的對(duì)象中的值的鍵

暮色呼如 2022-12-22 12:51:58
我有一個(gè)嵌套對(duì)象var obj = {"bn_IN":        {"status":"SUCCESS","language":"BENGALI","message":"Translated successfully"},"sq_AL":        {"status":"SUCCESS","language":"ALBANIAN","message":"Translated successfully"},"af_ZA":        {"status":"SUCCESS","language":"AFRIKAANS","message":"Translated successfully"},"da_DK":        {"status":"SUCCESS","language":"DENMARK_DANISH","message":"Translated successfully"},        "ar_DZ":{"status":"SUCCESS","language":"ARABIC","message":"Translated successfully"}}我需要從“BENGALI”值中獲取鍵“bn_IN”試過(guò):Object.keys(obj.filter(k=>obj[k]===BENGALI.toUpperCase())無(wú)法過(guò)濾
查看完整描述

1 回答

?
吃雞游戲

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊

您的問(wèn)題不清楚,但我假設(shè)您需要其值為對(duì)象且包含“語(yǔ)言”鍵的鍵,并且“語(yǔ)言”鍵的值應(yīng)為“BENGALI”。


//In the case of multiple keys

var obj = {"bn_IN":{"status":"SUCCESS","language":"BENGALI","message":"Translated successfully"},"sq_AL":{"status":"SUCCESS","language":"ALBANIAN","message":"Translated successfully"},"af_ZA":{"status":"SUCCESS","language":"AFRIKAANS","message":"Translated successfully"},"da_DK":

        {"status":"SUCCESS","language":"DENMARK_DANISH","message":"Translated successfully"},

        "ar_DZ":{"status":"SUCCESS","language":"ARABIC","message":"Translated successfully"}}


var keys=[]


for(key in obj){

     if(obj[key].language==="BENGALI") keys.push(key)

}


// In case if you know that key is unique


var obj = {"bn_IN":

        {"status":"SUCCESS","language":"BENGALI","message":"Translated successfully"},"sq_AL":

        {"status":"SUCCESS","language":"ALBANIAN","message":"Translated successfully"},"af_ZA":

        {"status":"SUCCESS","language":"AFRIKAANS","message":"Translated successfully"},"da_DK":

        {"status":"SUCCESS","language":"DENMARK_DANISH","message":"Translated successfully"},

        "ar_DZ":{"status":"SUCCESS","language":"ARABIC","message":"Translated successfully"}}


var key="";


for(key in obj){if(obj[key].language==="BENGALI") key=key}


查看完整回答
反對(duì) 回復(fù) 2022-12-22
  • 1 回答
  • 0 關(guān)注
  • 100 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)