Skip to content

Instantly share code, notes, and snippets.

Created September 14, 2019 15:16
What would you like to do?
Object destructuring
function getFirstLast(array) {
const {
0: first,
length: len,
[len - 1]: last
} = array
return {first, last}
getFirstLast(['apples', 'grapes', 'peaches', 'pears', 'cherries'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment