0

[arr[pivotIndex], arr[end]] = [arr[end], arr[pivotIndex]]

This line of code is part of the quickSort function. I understand the standard swap function but not this. Can someone explain to me how does this works? Thank you!

shayne
  • 1
  • 1
    It's like `let temp = [arr[end], arr[pivotIndex]];` (array creation) and `[arr[pivotIndex], arr[end]] = temp` (destructuring), except without actually creating the `temp` variable. – qrsngky Feb 28 '23 at 10:07

0 Answers0