Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix this missing semicolon syntax error in Javascript?

A friend wrote some code for me, and there was one file with a weird syntax error in it. After a bit of hunting, I narrowed it down to this section of code, which should reproduce the error:

var say = functіon(message) {   alert(message);   return message; };  say(say("Goodbye!"));

When I run this, I see an error in the Internet Explorer console that says SCRIPT1004: Expected ';'. I don't see a semicolon missing anywhere, and I can't imagine where it wants me to put one.

Where does it expect a semicolon and why does it expect a semicolon there?

like image 948
Peter Olson Avatar asked Feb 12 '12 02:02

Peter Olson


People also ask

What type of error is a missing semicolon?

The Missing Semicolon Before Statement error is a specific type of SyntaxError object.

Does JavaScript work without semicolon?

JavaScript does not require semicolons (other than the one exception you saw earlier). This is because JavaScript is clever and it can add the semicolons where needed automatically. This happens behind the scenes and you will not notice it. This process is called Automatic Semicolon Insertion (ASI).

Are you missing a semicolon TypeScript?

Semicolons are optional in JavaScript - TypeScript is a superset of JavaScript, ergo, semicolons are optional in TypeScript. That said, you will still run into issues with ASI like you would with JavaScript if you don't know where semicolons will be automatically placed.

What is the use of semicolon in JavaScript Class 10?

A semicolon is required When two statements are on the same line. So if you're going to put two statements on the same line, you have to separate them with a semicolon. The semicolon is only obligatory when you have two or more statements on the same line.


1 Answers

Your issue is the fact that the i in function is the unicode character i. If you change it to a 'normal' i it should just work.

But now I'm wondering how the hack :) did you get an unicode character there :P

unicode error in js

like image 65
PeeHaa Avatar answered Sep 18 '22 03:09

PeeHaa