can someone please explain how the following code changes the value of “xs”? it should remain the same

function allDifferent(xs){
   for(x of xs){

        let array1 = xs;
        let index = xs.indexOf(x);
        array1.splice(index, 1);

        if(array1.includes(x)){
           return false;
        }

   }
   return true;
}

I am trying to check if every element of the array “xs” is different by removing every element one by one and then checking if the remaining array still includes the value of that element somewhere else.

btw I already solved the problem in a different way so that i don’t need splice but i would just like to understand.