I am using lodash.js and am trying to remove a key pair from the below object based on the value not the key name - note, I cannot use the key name:
var filters = {
"filter1": "height",
"filter2": "length",
"filter3": "width"
}
This will remove a key pair by name
_.omit(filters, 'filter1');
Does anyone know how to removed it based upon value? Cheers
You can use _.omit
with a callback:
_.omit(filters, function (value) {
return value === 'width';
})