Given the example structure,
const selectedEdges = [
{ id: 'e1', start: 'n2', end: 'n1' },
{ id: 'e3', start: 'n6', end: 'n2' },
]
How do I compare nested array (nestedNodeNodeIds) with a plain array and the object
const nestedNodeIds = [['n1', 'n2'], ['n6']]
selectedEdges
.filter(({ start, end }) => !nestedNodeIds.includes(start) || !nestedNodeIds.includes(end)))
.filter(Boolean);
and return [{ id: 'e3', start: 'n6', end: 'n2' }]...??
It's returning [{ id: 'e1', start: 'n2', end: 'n1' }, { id: 'e3', start: 'n6', end: 'n2' }]
includes()comapres object references. SincenestedNodeIdsis initialized with two array literals, they're not gonna match anything inedgeById. Also a string doesn't have the propertiesstartandend, so I'm guessing your definition ofselectedEdgesis incorrect.