Destructuring parse console error - syntax?

If I put this code in the console I get an error on the destructuring line - line 7.
If I put a semi-colon after the console.log line then it works. Js tries to make the code into console.log()[] or something. I wonder if this is indeed an error from the parser or my code.

function shuffleArray(array) {
    for (let i = array.length - 1; i > 0; i--) {
        
      const j = Math.floor(Math.random() * (i + 1));
      console.log("i=",i,"j=",j)//error after this line - note no semi-colon.
      
      [array[i], array[j]] = [array[j], array[i]];
    }
}

array=[0,1,2,3,4,5
      ]
shuffleArray(array)
console.log(array)

Hello! Yes, your code has a type error.
We can see it in this reduced case:

console.log("hello")
[0]

without the semi colon, you’re trying to access an element from the result of the console.log call, and since console.log() returns undefined, you get this error.