Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
How to break or exit in Firebase object on child loop using jquery?

How to exit in a loop of object in Firebase after a certain condition. I tried using return false but it doesn't work. Can someone help me. Thanks in advance.

Here is my code:

function checkRoom(room_id,user_id,other_user){


    var  dbRefObject = firebase.database().ref('chat-list');
    //getting all keys 
    dbRefObject.on('child_added', function (snap) {
        if(snap.key == 1){
            //if condition succeed the loop will exit
            return false; //but return false is not working here.
        }
    });
}
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

To break out of a snapshot's forEach iteration, you need to return true.

The forEach method's action parameter is:

A function that will be called for each child DataSnapshot. The callback can return true to cancel further enumeration.

Note that you can break out of the iteration by returning any truthy value - not just true.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda