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

427
Views
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 answers
Answer question

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