0
我製作了一個查找表,其中的鍵是用戶名單的名稱。我已經將每個列表的值存儲在一個函數中,並且難以獲取值。如何在列表鍵中獲得特定值?從JavaScript查找表中獲取價值
的jsfiddle:https://jsfiddle.net/pgpx28r9/
我試圖:
var listLookupTable = {
'1': function(){
return {
'comments': 'a comment',
isPrivate:true,
revealAmazingStuff:false,
receiveFreeStuff:false,
receiveEmails:true,
}
},
'two': function(){
return {
comments: 'cool',
isPrivate:false,
revealAmazingStuff:false,
receiveFreeStuff:true,
receiveEmails:true,
}
},
'new stuff': function(){
return {
comments: 'another one',
isPrivate:true,
revealAmazingStuff:true,
receiveFreeStuff:true,
receiveEmails:true,
}
},
}
console.log(listLookupTable['1']);