Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!