Eclipse gives me the warning 'Missing semicolon' for line 4 of the following code:
const C = 'b';
function foo() {
alert('x');
}
It does not for the following code:
//const C = 'b';
function foo() {
alert('x');
}
For the following it gives me two warnings:
const C = 'b';
function foo() {
alert('x');
};
Multiple markers at this line
Is there a way to make Eclipse ignore my lines with 'const'? Or is there another way to solve my problem?
I am using:
Eclipse IDE for JavaScript Web Developers.
Version: Indigo Service Release 1
Build id: 20110916-0149
The JavaScript exception "missing ; before statement" occurs when there is a semicolon ( ; ) missing somewhere and can't be added by automatic semicolon insertion (ASI). You need to provide a semicolon, so that JavaScript can parse the source code correctly.
Semicolons are not required for JavaScript programming, nevertheless I advice you to use it. It makes your code more readable and is actually a good practice, and almost all cool programming languages uses it. Take a stand and use it, it's up to you now!
The rules of JavaScript Automatic Semicolon Insertionwhen the next line starts with code that breaks the current one (code can spawn on multiple lines) when the next line starts with a } , closing the current block. when the end of the source code file is reached. when there is a return statement on its own line.
Changing the semicolon to a comma would correct the sentence's error.
There is only a proposed const in JavaScript. Use
var C = 'b';
Actually, there is a const apparently, but it is not supported by all browsers and would not be good to use for that reason.
The reason Eclipse is giving you the warning is that it does not recognize const which is a known bug in Eclipse.
You can read how to ignore the errors in Use of JavaScript const gives "missing semicolon" in associative....
You may disable some warnings in the preference menu:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With