0
我有一個數組,我想存儲名稱,然後是一條信息,然後我可以調用該條目來檢索信息。當我嘗試搜索數組首先檢查的項目是數組中我收到:GenreArray.indexOf is not a function
無法抓取indexOf - 不是函數
我的代碼:
var GenreArray = {"00's":"Includes Amy Whinehouse, Westlife, The Killers...","90's":"Includes Britney Spears, Backstreet Boys, Mariah Carey..."};
if(GenreArray.indexOf("00's") > -1) //Crashed here
{
//Code here
console.log(GenreArray["00's"]);
}
如果我是把它變成帶[]數組;我怎樣才能做'00':「包含Amy Whinehouse',因爲我在元素列表錯誤後收到了'missing' – irishwill200
@ irishwill200 - 不確定你的意思。你想要數組看起來/ – tymeJV
我想存儲信息密鑰:信息,所以我可以檢查密鑰是否存在,如果是這樣的話..使用'array [key] [0]或者array [key]將信息顯示爲'info'' – irishwill200