JavaScript 根据对象某属性获得其在数组中的index

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);

转载于:https://www.cnblogs.com/wxxwjef/p/9054382.html

你可能感兴趣的:(JavaScript 根据对象某属性获得其在数组中的index)