Based on an object like this:
var p = [
{x: [
{x1: 1},
]
},
{x: [
{x1: 2},
]
}
];
I need to filter p objects when x1 is different from 1:
var p = [
{x: [
{x1: 2},
]
}
];
Thanks in advance.
1 Answer 1
var p = [
{x: [
{x1: 1},
]
},
{x: [
{x1: 2},
]
}
];
const results = p.filter(val => !val.x.some(v => v.x1 === 1));
console.log(results);
answered Jul 13, 2020 at 1:26
Adrian Brand
21.8k4 gold badges46 silver badges67 bronze badges
Sign up to request clarification or add additional context in comments.
4 Comments
Lian Nivin
Would you mind adding a response for
strings values? It would be great. Thanks.Adrian Brand
What sort of string response?
Lian Nivin
I mean how can I use a different method than
some. In some case that uses strings instead of 1 and 2 or any number.Lian Nivin
I just post that here: stackoverflow.com/questions/62869085/…
Explore related questions
See similar questions with these tags.
lang-js