-2
Is there any form of data forEach
be viewed outside the forEach
?
I need to see the data from forEach
out of it, but every time I do it it only returns the last data, not all data. I have tried using the localStorage
and the same result.
If not, there is some way to make a forEach
with two arrays? Could you give examples?
My code:
this.MetaService.CheckOrderGet().subscribe(
data => {
const pesquisa = (data as any)
this.check = JSON.parse(pesquisa._body)
this.check.forEach(apielement => {
this.fil.forEach(dados=> {
if (apielement.FI == dados.FI) {
console.log(`Dados iguais ${apielement.FI}`);
}else{
console.log(`Diferentes ${apielement.FI}`);
}
})
}
)
can not for a practical example to help understand? o
forEach
nothing else but check the elements of an array, you can inspect that array at any time, in other parts of the code. "le only returns the last data, not all data", yes, to each interaction an element is accessed, when it ends only has reference to the last, unless you store several elements... "has some way of making a foreach with two arrays?" no, the foreach is for one object (array, Collection) at a time, but you can do one inside the other if you want– Ricardo Pontual
I did one inside the other, but then I needed to compare the result of one with the other, and in that the results ended up being repeated, then the comparison did not have the correct result. I’ll put my code in to help
– Maria
@Maria here does not scroll to use one for and navigate the other array by Indice no? has any chance of array A being other than B?
– Willian
something else if vc for array[Indice][subindice]. obj vc navigate by it out of for each
– Willian
is that I need a specific data inside them, to be able to compare one with the other. I need to go through the array to access only one data of it @Willian
– Maria
Practically always the arrays will be different and will also have equal always
– Maria