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