这是我的训练:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
var fruits2 = fruits;
fruits2.reverse();
document.getElementById("demo").innerHTML = fruits+'<br>'+fruits2;
}
<p>Click the button to reverse only last array (fruits2).</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
当我反转fruits2
我的第一个变量(水果)时,也会改变,
我只是不想这样!我想一定很容易