I have this JSON object :
{
"active": 0,
"0": "active",
"inactive": 1,
"1": "inactive",
"ineligable": 2,
"2": "ineligable",
"error": 3,
"3": "error",
"suspended": 4,
"4": "suspended",
"archived": 5,
"5": "archived",
"removed": 6,
"6": "removed"
}
I want to filter the ones with a numerical value. The thing is I accomplished this already. But in a very ugly way and i wish to know if theres a better way to filter objects than the one I did.
Here's my try :
const statuses = listingstatus; //this is the object
let toFill = [];
Object.keys(statuses).forEach(key => {
if(Number.isInteger(statuses[key])){
toFill.push({[key]: statuses[key]});
};
});
console.log(toFill)
The result is this :
Array :
0: {active: 0}
1: {inactive: 1}
2: {ineligable: 2}
3: {error: 3}
4: {suspended: 4}
5: {archived: 5}
6: {removed: 6}