How to avoid adding an object to an array multiple times in JavaScript? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
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 Antwort
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