Skip to content

Instantly share code, notes, and snippets.

@nattatorn-dev
Last active April 17, 2017 03:50
Show Gist options
  • Save nattatorn-dev/04994441745385c6a0992b5bc2f4b58d to your computer and use it in GitHub Desktop.
Save nattatorn-dev/04994441745385c6a0992b5bc2f4b58d to your computer and use it in GitHub Desktop.
Head & Tail
Destructuring syntax allows us to get the head and tail of a list without utility functions.
_.head([1, 2, 3]);
// 1
_.tail([1, 2, 3]);
// [2, 3]
// becomes
const [head, ...tail] = [1, 2, 3];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment