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.

Bug 164626 - Trailing commas in Javascript Arrays
Summary: Trailing commas in Javascript Arrays
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: Macintosh All
: P3 blocker with 1 vote (vote)
Assignee: Petr Hejl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-06 17:32 UTC by kirkaustin
Modified: 2012-09-15 02:09 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot displaying the bug (5.76 KB, image/png)
2010-05-07 14:52 UTC, bfanger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kirkaustin 2009-05-06 17:32:38 UTC
While the editor does a good job of flagging trailing commas in JavaScript object literals, it does not flag trailing commas in arrays.  This is a bug when 
running in IE.
Comment 1 Marek Fukala 2009-05-07 09:46:43 UTC
Just to be sure, do you mean this?:

var myObjectLiteral = {
    'key1': value,
    'key2': value2, //DOES flag
}

var myArray = ["val1","val2",] //does NOT flag
Comment 2 kirkaustin 2009-05-07 18:43:17 UTC
Yes, you've got it right.
Comment 3 bfanger 2010-05-07 14:52:49 UTC
Created attachment 98638 [details]
Screenshot displaying the bug
Comment 4 bfanger 2010-05-14 15:46:54 UTC
Still not fixed in 6.9 
( NetBeans IDE 6.9 Beta (Build 201004200117 )
Comment 5 Martin Schovanek 2010-06-07 15:46:01 UTC
Selected by respondents of NetBeans 6.9 Community Acceptance survey as stopper, marking as 6.9.1_CANDIDATE.
Comment 6 tjcrowder 2010-09-27 12:15:24 UTC
Perhaps worth noting that the trailing comma is valid syntactically. Whether it was allowed in ECMAScript 3 (and what it meant if it was) was unclear and different implementations did different things (specifically, IE included an undefined entry in the array at the end, which wasn't unreasonable as that's what two commas in a row does; pretty much everyone else didn't, which also wasn't unreasonable). ECMAScript 5 expressly allows the comma (Section 11.1.4), and expressly defines that it does not cause an undefined entry at the end of the array. IE continues its old behavior up to at least IE8 (JScript 6).

Perhaps also worth noting that the trailing comma in an object literal is now valid as well (as of ECMAScript 5, Section 11.1.5). IE8 (JScript 6) no longer chokes on it, though all earier versions do.
Comment 7 Petr Pisl 2012-05-10 14:30:59 UTC
Needs to be check in the new JS Editor, when hints there will be implemented.
Comment 8 Petr Hejl 2012-09-14 11:23:58 UTC
Fixed in web-main 7699fa5883a5.
Comment 9 Quality Engineering 2012-09-15 02:09:39 UTC
Integrated into 'main-golden', will be available in build *201209150001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/7699fa5883a5
User: Petr Hejl <phejl@netbeans.org>
Log: #164626 - Trailing commas in Javascript Arrays