I know this question has been asked before, but I couldn't find a solution to this ... I'm simply doing this:
 var tagsToUse = [];
 var refTags = firebase.database().ref('/tag/');
        refTags.once('value', function(tags){
          pois.forEach(p=>{
            tags.forEach(function(t){
              if(p.tag == t.key){
                 console.log("Index " + tagsToUse.indexOf(t.child('name').val()))
                 if(tagsToUse.indexOf(t.child('name').val())==-1){o
                    tagsToUse.push(t.child('name').val())
                    console.log("Added "+ t.child('name').val())
                   }
               }
              return false;
            })
          })
        })
It keeps adding duplicates and the Index print is always -1, even if the name is already in the array. At the end I have an array with duplicates. What is wrong with that? Why is it printing -1? 
