I'm new to JavaScript/jQuery and there's probably an easy way to do this, but I'm unable to find the function or syntax I need. Basically, I have a set of objects like this:
{
"Object1": [
{
"Value": "ABC",
"IsEnabled": true
},
{
"Value": "DEF",
"IsEnabled": false
}
],
"Object2": [
{
"Value": "GHI",
"IsEnabled": false
}
]
}
And I want to turn it into a new set of objects based on the "IsEnabled" value equals true.
{
"Object1": [
{
"Value": "ABC",
"IsEnabled": true
}
]
}
If it's simpler, I would also be OK with not a new object, but the existing object with the "IsEnabled"=false objects removed. Any help is appreciated, thanks.
filter()
method do what you want?