const persons = [
{ id: 1, name: 'Shailesh', age: 29 },
{ id: 2, name: 'Prem', age: 37 },
{ id: 3, name: 'Mridula', age: 41 }
];
const copy1 = persons.slice();
const copy2 = [...persons];
Last active
February 22, 2019 20:04
-
-
Save sksundram/b59c4d3b72f020d22cfe41f411b69dc1 to your computer and use it in GitHub Desktop.
How to copy an array in JavaScript
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment