Understanding Array.slice() for Copying Arrays in Javascript


Create a shallow copy of an array or a portion of it.

Source Code

let numbers = [1, 2, 3, 4, 5];
let sliced = numbers.slice(1, 3);
console.log(sliced); // [2, 3]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments