CJCoding With Joseph
← Back to Question List
JavaScript Code Walkthrough #31

slice Copies, splice Cuts

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