JavaScript 根据对象某属性获得其在数组中的index
程序员文章站
2022-06-28 18:24:12
var arr = new Array({"name": "wxx", "age": 2}, {"name": "wyw", "age": 6});var index = arr.findIndex(function(item) { return item.name "wyw";});console ......
var arr = new Array({"name": "wxx", "age": 2}, {"name": "wyw", "age": 6});
var index = arr.findIndex(function(item) {
return item.name === "wyw";
});
console.log(index);