116
rated 0 times
[
122]
[
6]
/ answers: 1 / hits: 45652
/ 13 Years ago, thu, november 24, 2011, 12:00:00
I have the following object
{ join: {} }
I'd like to find it's default object from the array below
[
{ login: { label: 'Login', url: '#login' } },
{ join: { label: 'Join', url: '#join', theme: 'a' } },
{ home: { label: 'none', icon: 'home', url: '#', theme: 'a' } }
]
I'd like to loop through the array and match the key, in this case 'join'
.
This is what I have so far:
var butt_to_find = { join: {} }
var all_buttons = 'array above'
var matching = _.find(all_buttons, function(default_button){
return if default_butt key @ 1 is the same as butt_to_find key @ 1;
});
This is the first time I've used underscore after hearing so much about it.
Any help, more than welcome
More From » underscore.js