Q:

Recursive Insertion Sort with unexpected stack

I am trying to write the InsertionSort in recursive manner and I came up with the following code.
function recursiveInsertionSort(array) {
    sort(array, array.length - 1);
}

function sort(array, index) {
    if (index > 0) {
        sort(array, index - 1);
        let j = index - 1;
        let key = array[index];
        while (j >= 0 && array[j] > key) {
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = key;
    }
}

This code is working perfectly.
For example, if input is [4, 1, 3, 2, 16, 9, 10, 14, 8, 7], its returning [1, 2, 3, 4, 7, 8, 9, 10, 14, 16].
At line let key = array[index];, I am just trying to store the value at current index in a temporary variable and using it inside the loop. 
If I don't store it in a variable instead use it directly as shown in the following code, I am getting wrong output i.e., array is not sorted. I didn't understand why it is behaving that way. Even recursion stack seems to be perfect to me. But I am getting a weird output. 
function sort(array, index) {
    if (index > 0) {
        sort(array, index - 1);
        let j = index - 1;
        while (j >= 0 && array[j] > array[index]) {
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = array[index];
    }
}

For example, if input is [4, 1, 3, 2, 16, 9, 10, 14, 8, 7], its returning [ 4, 4, 4, 4, 16, 16, 16, 16, 16, 16 ]. 
Could any one please help me with this? This is actually shattering my understanding of recursion.

A:

array[index] is changed on first step.(when j is index - 1)
j = index -1
array[j+1] = array[j] => array[index]= array[index-1]

So if you don't save array[index] to key, you will lose data when sorting.

