DEV Community


Discussion on: Array '[]'

bladesensei profile image
coyla Author

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

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.