DEV Community

Discussion on: Array '[]'

Collapse
 
bladesensei profile image
coyla

Yes you are right for both suggestions,
Usually we use push as basic operation to add element.
I will remain forEach to show that loop is also used to get many elements by condition then i will add find method example too. Thanks

Collapse
 
kwiat1990 profile image
Mateusz Kwiatkowski

I would say that depends on what you need to do, it might be better to use either map or filter, which return a new array. It comes very handy in almost every situation. I used those both methods very often.