+ 2
Comma after last item in a list
In what situation(s) would it be suggested to add a comma after the last item/value in a list?
3 ответов
+ 3
In no situaton. A comma after your last item in the list has the effect that your last item isnt anymore the last item. With comma, here will be an empty field (a hole, undefiened) the last item.
0
IDK all the languages that do support this, but that's a new thing in JavaScript that's not even fully supported yet and will cause errors because of it in some browsers. The only good reason for it -- at least in JS -- is to make adding to the list easier in the future.
0
Thanks all. I only ask because there was an information box on question 2 of the 'list' section for python that stated: "Most of the time, a comma won't follow the last item in a list. However, it is perfectly valid to place one there, and it is encouraged in some cases."