swapping two values using array destructuring is not working without semicolon(;)

let [x,y] = [10,20] [y,x] = [x,y] console.log(x,y)

its not working as expected it gave me the error…

Uncaught ReferenceError: Cannot access ‘y’ before initialization

let [x,y] = [10,20];//using semicolon here [y,x] = [x,y] console.log(x,y)

now its working please anyone can explain me why its working now..`