3 ms·
I don't use JS, but in PHP you can add a comma after the last item, which I usually do, and therefore I don't have the problems that you encountered. Of course,
by Pheter 16y ago
I don't use JS, but in PHP you can add a comma after the last item, which I usually do, and therefore I don't have the problems that you encountered. Of course, I believe that people should do what works best for them, and if you find comma first easier to work with, then great!
Edit: And in response to your first comment about your IDE not supporting this: Is it not trivial to identify a syntax error in JS when you attempt to run it? Surely the intepreter (browser?) will notify you of the line that the syntax error occured on?
- edanm 16y agoYeah, I'm also used to adding a comma after the last item (in C, C++, Python). One of the problems is that this is an error in Javascript, but only in IE. Which means code will work fine while you develop, but when it comes time to test, it will suddenly stop working. The good thing about this way is that it's also very easy for humans to spot the error. Bottom line, catching the error while you code is always better than catching it after you compile. Also, this method has the advantage of working in all the languages I work in.