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);
博客列表 >JavaScript es6 根据对象某属性获得其在数组中的索引
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);