Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Actually JS does allow trailing commas. Read the spec.

It is an IE bug that causes it to break. One of the many ways they do not follow the spec.



It's the other way around. It was illegal in ECMAScript 3, which is what IE 8 and below (at the very least) implement:

  ObjectLiteral : 
      { } 
      { PropertyNameAndValueList } 

With ECMAScript 5 it is legal:

  ObjectLiteral : 
      { } 
      { PropertyNameAndValueList } 
      { PropertyNameAndValueList , } 

So before v5, the other browsers were incorrectly tolerating something that goes against the spec. It's only semi-recently that it's been "allowed" as a valid practice.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: