Last active
July 19, 2020 11:54
-
-
Save kjk/036ec15721848ba78806afd6f461c6e5 to your computer and use it in GitHub Desktop.
Example for https://essential-javascript.programming-books.io/copy-part-of-an-array-05cef06d3ae846b8b569c2b989e27dbf (made with https://codeeval.dev)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
let newArr = arr.slice(0, 2); | |
console.log("slice(0,2) :", newArr) | |
newArr = arr.slice(8); | |
console.log("slice(8) :", newArr) | |
newArr = arr.slice(5, -1); | |
console.log("slice(5, -1):", newArr) | |
newArr = arr.slice(6, -2); | |
console.log("slice(6, -2):", newArr) | |
newArr = arr.slice(3, 3) | |
console.log("slice(3, 3) :", newArr) | |
newArr = arr.slice(4, 1) | |
console.log("slice(4, 1) :", newArr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment