How to avoid adding an object to an array multiple times in JavaScript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to avoid adding an object to an array multiple times in JavaScript?

Hope you guys can help me

3rd May 2022, 2:51 PM
roshan roy
1 Answer
0
In any language, you can just check if the array already contains the object, like: if <Object> not in <Array>: <Add object>
4th May 2022, 6:10 PM
Emerson Prado
Emerson Prado - avatar