JavaScript 根据对象某属性获得其在数组中的index
程序员文章站
2022-03-18 16:49:44
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);
上一篇: 全方位分析web前端如何进行性能优化
下一篇: Python 面向对象之反射