【发布时间】:2016-05-17 12:52:16
【问题描述】:
我有一个 lodash 变量;
var usernames = _.map(data, 'usernames');
产生以下内容;
[
"joebloggs",
"joebloggs",
"simongarfunkel",
"chrispine",
"billgates",
"billgates"
]
如何调整 lodash 语句使其只返回唯一值数组?例如
var username = _.map(data, 'usernames').uniq();
【问题讨论】:
-
你试过
uniqBy吗?_.uniqBy(data, 'username') -
我希望数据能让我做到这一点……但这次我做不到。
标签: javascript node.js lodash