I have an object, having key and values. I'd like to pick the object and call the appropriate function from the key:
var requireViews = {
"breadCrumbView": true,
"headerView": false,
"footerView": false
};
var that = this;
_.each(requireViews, function(value, key){
if(value){ //if true?
if(_.functions(that, key)) that[key](); //checking is that function, and calling the function
}
})
Is it ok or can we minimize it further?
requireViews
used for? Could you add more context to your question? \$\endgroup\$ – 200_success Jun 5 '14 at 6:18