最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

'Missing semicolon' warning in Eclipse for JavaScript code - Stack Overflow

programmeradmin1浏览0评论

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

  • Unnecessary semicolon
  • Missing semicolon

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

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

  • Unnecessary semicolon
  • Missing semicolon

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

Share Improve this question edited Jul 24, 2016 at 11:25 Peter Mortensen 31.6k22 gold badges109 silver badges133 bronze badges asked Mar 1, 2012 at 8:41 user1027167user1027167 4,4387 gold badges35 silver badges41 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 9

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:

发布评论

评论列表(0)

  1. 暂无评论