Languages
[Edit]
EN

JavaScript - clone array

3 points
Created by:
Wiktor-Sribiew
800

In this article, we would like to show you how to clone an 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

Alternative titles

  1. JavaScript - fastest way to duplicate array
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

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