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

76
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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