Code Monkey home page Code Monkey logo

Comments (6)

hshoff avatar hshoff commented on May 5, 2024 2

@felixsanz yup! we switched to Babel which removes trailing commas and we get the added benefit of cleaner diffs. https://github.com/airbnb/javascript#19.2

from javascript.

op1ekun avatar op1ekun commented on May 5, 2024

Just watch out for IE browsers. If your last element is followed by coma IE will expect another element there (probably will whine about expecting object). Was a bit of hell back in the days of IE6...

It will give you trouble mostly ;) in IE6/IE7.

UPDATE: Of course I don't recommend it! Sorry for any confusion :)

from javascript.

serbanghita avatar serbanghita commented on May 5, 2024

IE7 throws error, also beware that IE9 in quirks mode (imagine a website that has no DOCTYPE) will throw the same error. I would not recommend this.

from javascript.

hshoff avatar hshoff commented on May 5, 2024

I would not recommend it as well. It has the potential to cause more trouble than the benefit it gives you.
Some implementations would actually add length to an array with a trailing comma:

Edition 5 clarifies the fact that a trailing comma at the end of an ArrayInitialiser does not add to the length of the array. This is not a semantic change from Edition 3 but some implementations may have previously misinterpreted this.

Source: http://es5.github.io/#D

from javascript.

trantorLiu avatar trantorLiu commented on May 5, 2024

Thanks for your comments. I think I will still keep this style in my projects (front-end and back-end). Since I am using the RequireJS optimizer module which removes trailing commas, I can avoid the compatibility issues while using this syntax sugar.

from javascript.

felixsanz avatar felixsanz commented on May 5, 2024

@hshoff So now this changed?

from javascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.