Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda