Given this JSON object, how does lodash remove the reach
value from the objects?
{
total: 350,
SN1: {
reach: 200,
enga
use _.mixin to extend a omitDeep method:
_.mixin({
'omitDeep': function(obj, predicate) {
return _.transform(obj, function(result, value, key) {
if (_.isObject(value)) {
value = _.omitDeep(value, predicate);
}
var doOmit = predicate(value, key);
if (!doOmit) {
_.isArray(obj) ? result.push(value) : result[key] = value;
}
});
}
});
var my = {
"key1": {
"key2": {
"key3": [null, {
"key4": "string",
"key5": true,
"key6": null,
"key7": 8,
"key7": undefined
}, null]
}
}
};
console.log(my);
console.log("omit null:", _.omitDeep(my, _.isNull));
console.log("omit undefined:", _.omitDeep(my, _.isUndefined));