<!DOCTYPE html>
<html>
<body>
<p>Click the button to copy the first two array elements to the last two array elements.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<p><strong>Note:</strong> The copyWithin() method is not supported in IE 11 (and earlier versions).</p>
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
document.getElementById("demo").innerHTML = fruits.copyWithin(2,0);
}
</script>
</body>
</html>