Skip to content
Advertisement

I need to find a specific value in an array of arrays. Angular, Typescript

I need to find a value in an array of arrays, but when I use the .find it returns undefined

JavaScript

The array of arrays is datos. And this is the Html:

JavaScript

I have tried to access to the datos array of arrays and it returns an empty array, I want to use the array of arrays to display a table an after this get an specific value of the table, using .find().

Advertisement

Answer

Assuming datos: [][] is a nested array of strings, you could use flatMap with find:

JavaScript

That being said, if datos is a nested array of objects, you can’t simply compare {} === {}, you would need to compare against some kind of property object:

JavaScript

Version without flatMap:

JavaScript

Hopefully that helps!

Advertisement