I have an array called mainarray which has multiple json objects.
mainarray:Object
>key1: Array[30]
>key2: Array[20]
I want to do sorting on Array[30] and Array[20]. I am trying to do it like this:
mainarray.forEach((arrayinner)
{
//sort
});
But I am getting error : as Cannot read property of undefined.
How can I iterate ? and also key names are dynamic ,I cant hardcode it and start iterating/
mainarray.forEach((arrayinner) => { // sort })in fact for a single argument you don't even need the parentheses and do likemainarray.forEach(arrayinner => { // sort })and then the idea behind inline arrows is to cut the code short. So no point in using long variable names and you can reduce your code more likemainarray.forEach(a => { // sort })