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

106
Visualizações
join is removing escape of escaped string

Why are the \ removed in the result and how can I prevent this? I need to keep the escaped string as it is.

const result = [
  'TITLE=Frontend',
  'DESCRIPTION=The\ frontend\ application'
].join('\n')

Expected result is:

TITLE=Frontend
DESCRIPTION=The\ frontend\ application

Update

The other way would be to join the string and escape the complete string after joining. I think this would be even better...

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

join() isn't removing anything. The backslash isn't in the original strings. It's just escaping the spaces, but space doesn't require escaping.

You need to escape the backslash if you need it to be included in the string literally.

const result = [
  'TITLE=Frontend',
  'DESCRIPTION=The\\ frontend\\ application'
].join('\n')

console.log(result);

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