[英]How to get difference values between an array of values and array of object using lodash
I have two array as我有两个数组作为
a1 = ['test1@gmail.com','test2@gmail.com','test3@gmail.com'];
a2 = [{email: 'test1@gmail.com'},{email: 'test2@gmail.com'}];
Now I want to get difference between these two array mentioned above as现在我想得到上面提到的这两个数组之间的区别
resultDifference = ['test3@gmail.com'];
How to achieve this difference result by using lodash only.如何仅使用 lodash 来实现这种差异结果。
You should add what you have tried to your post您应该将您尝试过的内容添加到您的帖子中
const a1 = ["test1@gmail.com", "test2@gmail.com", "test3@gmail.com"];
const a2 = [{ email: "test1@gmail.com" }, { email: "test2@gmail.com" }];
const ans = _.difference(
a1,
a2.map((a) => a.email)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.