Last active
January 11, 2022 14:39
-
-
Save ancyrweb/3b7168b5c13e7a51bf270973531d0017 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 elements = [1, 2, 3, 4, 5]; | |
// remove last element | |
const lastElementRemoved = elements.slice(0, 4); // [1, 2, 3, 4] | |
// remove first element | |
const firstElementRemoved = elements.slice(1); // [2, 3, 4, 5] | |
// remove first and last element (chaining) | |
const firstAndLastElementRemoved = elements.slice(0, 4).slice(1) // [2, 3, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment