Last active
July 10, 2020 09:52
-
-
Save lucas-nguyen-17/6bd24593f95bbf9d2880af6d7233f335 to your computer and use it in GitHub Desktop.
Get array based on condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var users = [ | |
{ 'id': '123', 'name': 'giang' }, | |
{ 'id': '456', 'name': 'nguyen' }, | |
{ 'id': '789', 'name': 'nguyen' } | |
]; | |
var filters = _.filter(users, function(user) { | |
return user.name === 'nguyen'; | |
}); | |
var ids = _.map(filters, 'id'); | |
console.log(ids) | |
//show ["456", "789"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment