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

112
Visualizações
JavaScript escape characters, same strings but different representation in browser

I have two strings. One is constant and another comes from firebase firestore. both are the same strings.

First one is local string:

const str =
              "3\r\n4 9\r\n2 7 11 15\r\n5 4\r\n2 3 1 15 7\r\n4 31\r\n16 1 15 7";

And another is string from firebase firestore:

{
    str: "3\r\n4 9\r\n2 7 11 15\r\n5 4\r\n2 3 1 15 7\r\n4 31\r\n16 1 15 7",
}

When I try to compare these two I get false output to console:

console.log(str === docSnapshot.data().str); // output: false

When I log both strings to console I get this output.

For first one:

console.log(str);

**output-**
3
4 9
2 7 11 15
5 4
2 3 1 15 7
4 31
16 1 15 7

For firestore sting:

console.log(docSnapshot.data().str);

**output-**
3\r\n4 9\r\n2 7 11 15\r\n5 4\r\n2 3 1 15 7\r\n4 31\r\n16 1 15 7

    

Please help me understanding this. And how can I log firebase string to console same as first one?

about 4 years ago · Santiago Trujillo
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