Last active
September 1, 2018 11:53
-
-
Save NathanKleekamp/acbbed7fc93c91c04a520c78ed484fee to your computer and use it in GitHub Desktop.
A JS utility to get all but the first items in an array
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 rest = array => array.slice(1, array.length); | |
const rest = ([first, ...rest]) => rest | |
const testArray = [1, 2, 3, 4, 5]; | |
rest(testArray) // [2, 3, 4, 5]; | |
rest([]).length === 0; // true | |
Array.isArray(rest([])); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment