CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

slice Copies, splice Cuts

JavaScript code walkthrough · Question 31
mediumArrays

Code

Read carefully. What does this print?
1let arr = [1, 2, 3, 4, 5];
2let s = arr.slice(1, 3);
3console.log(s.join(","));
4let removed = arr.splice(1, 2);
5console.log(removed.join(","));
6console.log(arr.join(","));

Your answer