无法获取 indexOf - 不是函数

Cant grab indexOf - is not a function

我有一个数组,我想存储名称和一条信息,这样我就可以调用该项目来检索信息。当我尝试搜索数组以首先检查该项目是否在我收到的数组中时:GenreArray.indexOf is not a function

我的代码:

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"]);
}

GenreArray是一个对象,一个对象包含key/val对,不是索引。你可以做 hasOwnProperty

if (GenreArray.hasOwnProperty("00's")) {

}

(因此将该变量重命名为 'GenreObj' 可能有意义)