This algorithm does not modify the original array. The very first line is:
// Create a sortable array to return.
const sortedArray = [ ...unsortedArray ];
By mutating the copy,
sortedArray, the original array remains unmutated.
This choice is significantly more performant than an alternative that does not perform any mutations. The latter option would require much more memory, as each split into “sort all values less than pivot” and “sort all values greater than pivot” would double the memory consumption. Your Big O for memory consumption would be astronomical.