Articles → JAVASCRIPT → Clone An Array Using The Spread Operator In Javascript
Clone An Array Using The Spread Operator In Javascript
Example
<script>
numbers = [1, 2, 3];
clonnedNumbersArray = [...numbers]; // cloning an array using the spread operator
document.write("Length of the clonned array:" + clonnedNumbersArray.length);
</script>
Output