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
Posted By - | Karan Gupta |
|
Posted On - | Monday, August 23, 2021 |