Skip to content

JavaScript errorSyntaxError: “missing ) after argument list”

A script fails to load with SyntaxError: missing ) after argument list (Safari: Expected ')' to end an argument list). The parser was reading the arguments of a function call, met something that cannot continue an argument, and expected the closing parenthesis instead. The mistake is inside the call on that line, not after it.

Short answer

Look inside the function call on the reported line. The usual causes are two values with no + or comma between them (console.log('Total: ' total)), a quote inside a string that ends the string early ('it's'), a missing comma between arguments, or a bracket or brace opened inside the call and never closed. Template literals avoid most quoting and concatenation mistakes: console.log(`Total: ${total}`).

Why the call is not closed, and the fix

  1. 01

    A missing + or comma between values

    “There is an error with how a function is called. This might be a typo, a missing operator, or an unescaped string, for example.” MDN, SyntaxError: missing ) after argument list

    Two values side by side inside a call, with nothing joining them, end the argument too early. Add the operator or comma, or use a template literal.

    // SyntaxError: missing ) after argument list
    console.log('Total: ' total);
    
    console.log('Total: ' + total);
    console.log(`Total: ${total}`);
  2. 02

    A quote that ends the string early

    An apostrophe inside a single-quoted string closes it, and the rest of the text is read as code. Escape it, switch quote style, or use a template literal.

    alert('It\'s done');
    alert("It's done");
    alert(`It's done`);
  3. 03

    The call’s own closing parenthesis is missing

    When a call ends with an object or callback and the final ) is lost, the parser runs into the next statement and reports this error there. An unclosed { or [ inside the call gives Unexpected token ')' instead. Formatting the file with Prettier shows where the nesting goes wrong.

    fetch(url, {
      method: 'POST',
      body: JSON.stringify(data),
    }   // missing ) here
    console.log('sent');
  4. 04

    Text that is not JavaScript inside the call

    A stray character from a copy and paste, a comment marker in the wrong place, or template syntax from another language (such as {{ value }}) inside a call often stops the parser with this error or a nearby one such as Unexpected token. Retype the arguments by hand.

Checked against the vendor’s docs on : MDN: SyntaxError: missing ) after argument list.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: “SyntaxError: Unexpected identifier” · “Invalid or unexpected token” · TypeError: “x is not a function”

Questions

More on this error

The parentheses on the line are balanced. Why the error?

Balanced brackets are not enough: the content between them must be valid. Look for two values with no operator between them, or a string that ends early.

Why does this error mention a line in HTML?

Inline handlers such as onclick="..." are JavaScript too. A quote inside them that matches the HTML attribute quote ends the attribute early. Move the code into a script and add the listener there.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.