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

87
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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