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
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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
I would say that depends on what you need to do, it might be better to use either
map
orfilter
, which return a new array. It comes very handy in almost every situation. I used those both methods very often.