I have two arrays and I want to copy some values from one to the other, spefically those values in indexes greater than the length of the first array.

```
var arr1 = [1,2,3];

var arr2=  [1,2,3,4,5,6,7];

```

if I do this:

```
var length = arr1.length;

for(var i = length; i < arr2.length; i++){
    arr1.push(arr2[i]);
}

```

I presume that that `i` will be initalized and then that length value will never be revisited so even if the length changes as arr1 changes, that won't matter.

But my question is, to mitigate any potential bugs, I could just copy the value of arr1.length into a new variable.

So I could do this:

```
var length = JSON.parse(JSON.stringify(arr1.length));

for(var i = length; i < arr2.length; i++){
    arr1.push(arr2[i]);
}

```

or maybe more simply:

```
var length = Number(arr1.length);

for(var i = length; i < arr2.length; i++){
    arr1.push(arr2[i]);
}

```

my question is ultimately - how can I copy the value from an array's current length and store it in separate variable that won't change?