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

419
Visualizações
Double quote escape is giving Uncaught SyntaxError: missing )

I Have an issue where user last name(adfs2"k) which has double quote, whenever I need to edit the last name and click on a button, it throws an error

Uncaught SyntaxError: missing ) after argument list

I have tried the double quote escape, but it still throws

lastName = lastName.replace(/\"/g,"\\\"");

and this is the function, i'm using

"javascript:editUserEmailPopup(' + "'" + firstName + "'" + ',' + "'" + lastName + "'" + ');"
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As @T.J. Crowder suggests in his comment, one cause of this issue is embedding your function call within an HTML attribute. Using these inline-event-handlers can lead to problems like this as well as unmanageable code. The alternative is to use an external script tag, or to inline a script tag.

However, even within an isolated script, this code has some issues that make it unclear what it should even do and does not work. I believe the code is meant to return the firstName variable surrounded by double quotes, followed by the lastName variable surrounded by single quotes. The code is unclear but this solution should be able to fix it:

const firstName = 'asd5"3'
const lastName = "jfni8'543"
console.log(`"${firstName}", '${lastName}'`)

This syntax of embedding variables into strings and being able to use double quotes and single quotes without escaping them is called Template literals:

Template literals are enclosed by the backtick ( ) (grave accent) character instead of double or single quotes.
Template literals can contain placeholders. These are indicated by the dollar sign and curly braces (${expression}). The expressions in the placeholders and the text between the backticks ( ) get passed to a function.
(From MDN)

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