+ 2

What is the use of trailing commas

I need a cool example. Honestly this added feature in ES6 doesn't make much scense to me. I need an example to show how important it is. https://code.sololearn.com/WAhSwO93O66C/?ref=app

27th Feb 2023, 9:17 AM
Learning Python
1 Answer
+ 6
"Trailing commas (sometimes called "final commas") can be useful when adding new elements, parameters, or properties to JavaScript code. If you want to add a new property, you can add a new line without modifying the previously last line if that line already uses a trailing comma. This makes version-control diffs cleaner and editing code might be less troublesome." (Here you also find cases of trailing commas that are allowed) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas
27th Feb 2023, 9:53 AM
Lisa
Lisa - avatar