How to use the Array.of() Method In Javascript
This method creates a new array with the same elements as the original array.
Example: This example shows the implementation of the above-explained approach.
const originalArray = [1, 2, 3];
const clonedArray = Array.of(...originalArray);
console.log(clonedArray);
Output
[ 1, 2, 3 ]
How to clone an array in JavaScript ?
In JavaScript, cloning an array means creating a new array with the same elements as the original array. Cloning an array in JavaScript is useful when you want to create a new array that has the same elements as an existing array, without modifying the original array.
Contact Us