I'm trying to learn swapping the elements in the array using destructuring concepts in javascript.
var arr = [1, 2, 3]
[arr[2], arr[1], arr[0]] = arr
console.log(arr);
I thought the console will print [3, 2, 1].
But it came error like
TypeError: Cannot read properties of undefined (reading '2')
I don't need an alternative method to get output, I want to learn that why undefined error came?