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

78
Views
chrome's console.log string substitution seems out of control

I'm trying to show a string using console.log. I just want to show the string (not have it interpreted as a format string).

Example string: 'here are two percents: %%'

My attempts to print it (google-chrome Version 100.0.4896.127):

  console.log('here are two percents: %%')
  // wrong output: 'here are two percents: %'

  console.log('%s', 'here are two percents: %%')
  // wrong output: 'here are two percents: %'

  console.log('%s', '%s', 'here are two percents: %%')
  // wrong output: 'here are two percents: %'

  console.log('', 'here are two percents: %%')
  // wrong output: ' here are two percents: %%'

Note the undesired leading space, in the last attempt.

How can I get the desired output 'here are two percents: %%' ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

For one thing, what you're seeing is a Chrome-specific problem (I'd even go as far as to call that a bug, you should report it). On Firefox, the output is much more sane:

enter image description here

However, a portable way to get your string printed as is is to use console.dir() instead, that seems to work on both Chrome and Firefox as expected.

about 4 years ago · Juan Pablo Isaza Report
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!