📌  相关文章
📜  通过键值js获取数组索引 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:02.600000             🧑  作者: Mango

代码示例1
var peoples = [
  { "attr1": "bob", "attr2": "pizza" },
  { "attr1": "john", "attr2": "sushi" },
  { "attr1": "larry", "attr2": "hummus" }
];

var index = peoples.map(function(o) { return o.attr1; }).indexOf("john");
console.log("index of 'john': " + index);