the data goes like this:
var obj = [
{
id:1,
name:""
},
{
id:2,
name:""
},
{
id:3,
name:""
}
];
now I want to know what the subscript for "Xiao Hong" is for name
//,
function findIndex(arr,key,word){
arr.map((o,n)=>{
if(o[key] == word){
return n;
}
})
}
var t = findIndex(obj,"name","");
console.log(t); //underfine