Uncaught SyntaxError: Unexpected token = in Chrome

While working on a project I got a JavaScript error saying Uncaught SyntaxError: Unexpected token = in Google Chrome while Firefox  was performing fine. I searched on Google for similar questions but couldn’t get the issue with my code. Still later after finding solution for this Uncaught SyntaxError, I decided to post an article as below.

Uncaught SyntaxError: Unexpected token = in Chrome

The problem was that JavaScript doesn’t allow you to pass default parameter to function. We need to assign the default value internally to function. Check the code below:

As I was using default parameter feature and it is supported only by Firefox. So I removed default assignment of argument to ‘count‘ parameter from function and redefine in the following manner to deal with Uncaught SyntaxError: Unexpected token =,  error appearing in Google Chrome.

Which kicked out the issue from Chrome.

You Might Interested In

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.