How to use structuredClone() Method In Javascript
We can also use the modern structuredClone() method for deep cloning of an array. This can be done using the structured clone algorithm.
Example:
const arr = ["w3wiki","geek","GFG","geeks"];
const newArray = structuredClone(arr);
console.log(newArray);
Output:
['w3wiki', 'geek', 'GFG', 'geeks']
How to Copy Array by Value in JavaScript ?
In this article, we will see how to create a copy of an array by value using JavaScript. Javascript has various ways to clone the array.
We can use some methods to create a copy of an array that is given below:
Table of Content
- Using Spread Operator
- Using Array.from() Method
- Method 3: Using Array.slice() Method
- Using structuredClone() Method
- Using the map()
Contact Us