我有 2 个对象列表:
people =
[{id: 1, name: "Tom", carid: 1},
{id: 2, name: "Bob", carid: 1},
{id: 3, name: "Sir Benjamin Rogan-Josh IV", carid: 2}];
cars=
[{id: 1, name: "Ford Fiesta", color: "blue"},
{id: 2, name: "Ferrari", color: "red"},
{id: 3, name: "Rover 25", color: "Sunset Melting Yellow with hints of yellow"}];
是否有一个函数(可能在 Angular、JQuery、Underscore、LoDash 或其他外部库中)在这些上的一行中进行左连接?就像是:
peoplewithcars = leftjoin( people, cars, "carid", "id");
我可以自己编写,但如果 LoDash 有优化版本,我想使用它。