0
Good morning,
I saw about allocation via structuring and swap on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Atribuicao_via_desestruturacao, but I saw that if I make the following code:
var [a, b] = [1, 2] {1}
console.log(a) //1 {3}
console.log(b) //2 {4}
[b, a]=[a, b] {6}
console.log(a) //2 {7}
console.log(b) //1 {8}
without ";" at the end of the console.log(b) of the line {4} returns the error Cannot set Property '1' of Undefined, but if I put the ";" the algorithm works normally.
My question is as follows: since ";" is optional in javascript why I need to put in this case?