JSFiddle - React, Tailwind, and code Playground
by marcgrabow
JavaScript
// My big object
var bigObject = {
prop1: {
prop2: {
prop3: 123,
prop4: 456,
prop5: "TEST"
},
prop6: 789,
prop7: "xxx"
},
prop8: 5.6,
prop9: 3
};
// My "interface" to filter the object
var filterInterface = {
prop1: {
prop2: {
prop3: true,
},
prop7: true
}
};
// My expected result, only the properties of big Object which match the interface
var filteredObject = {
prop1: {
prop2: {
prop3: 123,
},
prop7: "xxx"
}
};
// QUESTION
// How to filter bigObject with filterInterface to get filteredObject?