I am trying to do something in pure JS. I have an Object like so
var data = {
"Something": true,
"Something else": false,
"Blah": false,
"a fish ISA": true
};
What I want to do is filter anything which has true to its own Object. At the moment I am trying
var thingFunctions = Object.keys(data).filter(function(e) {
return typeof data[e] == 'function'
});
But I think this is incorrect. How can I get the data with a value of true to its own Object?
Thanks
typeof data[e] == 'function'has nothing to with true or false booleans - you should be looking at something liketypeof data[e] == 'boolean' && !!(data[e])data[e] === true