JavaScript Syntax​Error: missing ) After Argument List

Article By Digamber Rawat on

Let us understand SyntaxError: missing ) after argument list error in JavaScript. This error occurs when a function is called in JS. It can occur due to various reasons.

Error Reasons:

  • missing operator
  • typo error
  • unescaped string

Check out some examples

As you can see we are trying to generate a random number using Math.random() method In the below example. However, this method won’t work because we are missing “+” operator in the console.log() method.

console.log('Random Number: ' Math.random());

// Output: SyntaxError: missing ) after argument list

Let us fix this SyntaxError: missing ) after argument list error in JavaScript by putting "+" operator and check out the output below.

console.log('Random Number: ' + Math.random());

// Output: some random number between 0 and 1

SyntaxError: Invalid or unexpected token

console.log('"Hello" + "World"");

// Output: SyntaxError: Invalid or unexpected token

As we can see JavaScript throw SyntaxError: Invalid or unexpected token error because of missing " ' ".

console.log('"Hello" + "World""');

// Output: "Hello" + "World""
Digamber Rawat

Feel free to contact me, If you are looking for a freelance full stack Developer, with the following skills: Mongo DB, Express JS, Angualr 2+, Node JS, Loopback JS, Firebase, Ionic Framework and WordPress. I also offer remote contracting service to the clients across the globe. Hire Me