when i am taking values into x and y using destructuring its working. but when I am trying to swap the values using Destructuring its simply showing Typeerror. I have searched this problem on the internet and found no solution any help would be appreciatable.
const arr=new Array(2,3,4);
let [x,y,z]=arr;
console.log(x,y)
let a="23";
let b="20";
console.log(a,b)
[a , b] = [b , a];
console.log(a,b)
// [x,y]=[y,x];
console.log(x,y)
i am expecting the values of a and b to be sawpped.