Lodash map and return unique

Many ways, but uniq() isn’t a method on array, it’s a lodash method.

_.uniq(_.map(data, 'usernames'))

Or:

_.chain(data).map('usernames').uniq().value()

(The second is untested and possibly wrong, but it’s close.)

As mentioned in the comment, depending on what your data actually is, you could do this all in one shot without first pulling out whatever usernames is.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)