let arr=[{
id:1,name:"hhh"},
{
id:2,name:"eee"},
{
id:3,name:"yyy"}
]
let name = arr.find(o => o.id == 2).name;
console.log(name)//eee
js 通过id名找到对象数字里对应的name
于 2022-11-09 15:08:56 首次发布
let arr=[{
id:1,name:"hhh"},
{
id:2,name:"eee"},
{
id:3,name:"yyy"}
]
let name = arr.find(o => o.id == 2).name;
console.log(name)//eee