This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
NB 7.2 handled this fine, but NB 7.3 claims "Expected an operand but found const" for a simple line like this one: const pi = 3.14;
This comes from parser. In NB 7.2 was used Rhino parser, in NB 7.3 is used Nashorn parser. The current implementation of const is a Mozilla-specific extension and is not part of ECMAScript 5 and this is the reason, why it worked in NB 7.2. The Rhino parser is Mozilla's parser. The proper fix should be on parser site, in NetBeans I can filter the message, but is not very nice approach.
I made some tests, Chrome and Mozilla handles const keyword. However, even internet explorer 10 fails. Therefore, it's safe not to use const keyword.
I know that IE does not recognize it, but that's a Microsoft issue. const is part of the JavaScript language and as such should be recognized correctly.
to geverl: const is not a part of JavaScript specification ECMAScript-262 Edition 5.1 language (fallowed with Nashorn). As I wrote - const is a Mozilla-specific extension and is not a part of ECMAScript 5. So from this point of view it depends how you specify JavaScript language. So I can block the message in the editor, but the file will not be fully parsed by the parser.
OK, thanks for your explanations. I can live without const, so I'm just going to mark this as resolved.
I make use of many libraries that use const and as a result Netbeans is not working properly. Lets at least add an option to ignore this parser error?
I want to echo the comment to let us ignore the error. I sometimes work with libraries which use const and am developing code which is mozilla-only (for an Add-on). I don't care that IE doesn't support it, I just need to suppress the errors without having to revert back to 7.2
*** Bug 239881 has been marked as a duplicate of this bug. ***
'const' is not in ECMAScript 5, but it will be in ECMAScript 6: http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#current_working_draft As others, I also depend on 'const' because I develop Mozilla add-ons. Please, implement this.
Have to use it too, and the IDE shows me the same error: "Expected an operand but found const". Voted.
Also, Mozilla now documents 'const' keyword at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
*** This bug has been marked as a duplicate of bug 238942 ***