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?
Is there a simple way to use Underscorejs to achieve this?
javascript;underscore.js
If you add a filterObject mixin (this is the one I usually use), it will be easy_.mixin({    filterObject: function(obj, predicate, context) {        return _.reduce(obj, function(memo, val, key) {            if (predicate.call(context, val, key, memo)) memo[key] = val;            return memo;        }, {});    }});Now its simple and elegant :)_.invoke(this, _.values(_.filterObject(requireViews, Boolean)));If you like underscores you can use the ridiculous algorithm below (don't do it!)_.invoke(this, _.map(_.filter(_.pairs(requireViews), _.partial(_.every, _, Boolean)), _.first))