So lets say I have a variable called array:
var array = [1,2,3]
when I use the reverse()
method it reverses the array, as expected
array.reverse()
but lets say I want to keep the original variable so I make a "temporary" variable
var array = [1,2,3]
var arrayRev = array.reverse()
console.log(arrayRev)
console.log(array)
but array is also reversed. how do I know when the original variable changes and when it doesn't?
Thanks if you can help