Languages
[Edit]
EN

JavaScript - clone array

3 points
Created by:
Wiktor-Sribiew
350

In this article, we would like to show you how to clone array in JavaScript.

Quick solution:

// ONLINE-RUNNER:browser;

let letters = ['A', 'B', 'C'];
let copy = letters.slice();

console.log(letters);
console.log(copy);

Note: to see all approaches how to copy array check this article.

See also

  1. JavaScript - copy array

JavaScript - Arrays (popular problems)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join