How to avoid adding an object to an array multiple times in JavaScript? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
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 Réponse
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