K
K
Kant2010-09-13 11:40:58
JavaScript
Kant, 2010-09-13 11:40:58

Extra comma in JS

There was a dispute about an error that occurs in IE if an extra comma is encountered in the code.
The situation is simple: If the last comma is not removed, IE does not process the script. All other browsers will work with a bang. Question: Who is right? The coder and his comma (along with all browsers) or IE (which doesn't want to handle a clear programmer's mistake).
items: [
{xtype: 'textfield', cls: 'fake-field', value: 'Manager Login'},
new Ext.form.TextField(Ext.applyIf({fieldLabel: 'Username', name: 'login', allowBlank:false}, fieldConfig)),
this.passwordField,
this.passwordConfirmField,
new Ext.form.Hidden({name: 'companyId'}),
]

Answer the question

In order to leave comments, you need to log in

9 answer(s)
C
charon, 2010-09-13
@charon

in my unprofessional opinion, the programmer is wrong. The comma is clearly superfluous here, in whatever grammar you think.

H
Hackett, 2010-09-13
@Hackett

Explains everything .

C
Chvanikoff, 2010-09-14
@Chvanikoff

To be a comma at the end of enumerations!
And IE... Well, it's always been "special".

K
Kant, 2010-09-14
@Kant

In general, we figured it out: commas are allowed in the 5th edition of ECMA-262, but browsers only support the 3rd edition, in which commas are not allowed.

A
Anton Korzunov, 2010-09-13
@kashey

The proger is wrong, and for some reason we have a lot of people who are not right at work.
And not only in JS,
probably because people are not Sishniks and not even Pascalists - but any “normal” languages ​​​​hardly kill any syntax violation.
And they teach not to write extra quotations very quickly

P
Pavlo Ponomarenko, 2010-09-13
@TheShock

wrong IE, because, according to the standards, a comma at the end can stand. this is done for the convenience of programming and code generation

M
MT, 2010-09-13
@MTonly

With arrays (Array) in IE (even 6) there seems to be no such problem, but as for objects used as associative arrays, this has already been fixed since IE8:

var obj = {
	'lorem' : 'first',
	'ipsum' : 'second',
};

In total, the programmer is right, but because of IE6-7, it is still inconvenient to do it - without a comma after the last element.

M
Mark, 2010-09-13
@printf

According to the standard, a comma is not allowed there. IE is right (this is probably the only such case).

A
Alexander Kolobov, 2010-09-15
@Aleko

I'm interested in something else, why does ie fall, bumping into this comma? For me, it worked quite well in cases like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question