About Lesson
It is JavaScript lesson we are going to learn about JavaScript Trailing Commas, so trailing commas comes at the end of the last item in a list, and it is a feature in JavaScript ES8.
Now let’s create an example, so you can see that after our last item in the array, we have added a comma, and there is no problem with this syntax, and we will not receive any error, because it is a feature in JavaScript ES8.
1 2 |
const number = [1,2,3,4,5,6,]; console.log(number); |
Also you can add training commas in a function, you can see in the function after adding the second parameter we have added a comma and this is a valid syntax.
1 2 3 4 5 |
function add(a,b,) { return a+b; } console.log(add(4,5)); |