js object array filter to get the object you want [super simple way to filter]
Scenes:
I forgot where I saw it, but it is very convenient to use anyway, so record it.
The js object array filters the objects you want according to the attribute value
code:
var driverList = [{driverId:'1',name:'张一'},{driverId:'2',name:'张二'},
{driverId:'3',name:'张三'}];
//根据id获取张三 获取数组对象指定元素
var driver = driverList.filter(x=>x.driverId == '3')[0];
console.log("对象是:",driver.name);