Answer the question
In order to leave comments, you need to log in
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
in my unprofessional opinion, the programmer is wrong. The comma is clearly superfluous here, in whatever grammar you think.
To be a comma at the end of enumerations!
And IE... Well, it's always been "special".
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.
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
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
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', };
According to the standard, a comma is not allowed there. IE is right (this is probably the only such case).
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 questionAsk a Question
731 491 924 answers to any question