javascript - reactjs can I flat an array -


i have following code:

usersarray.foreach(user => {    users.push(data.users.filter(useraws => useraws.username === user.username))  }); 

this returns arrays in arrays.

enter image description here

but want add inner object direktly outher array.

how can flatten inner array?

thanks

update

usersarray.foreach(user => {             users.push([].concat.apply([], data.users.filter(useraws => useraws.username === user.username)))         }); 

solution this:

users.push(...data.users.filter(useraws => useraws.username === user.username)) 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -