Skip to content

Instantly share code, notes, and snippets.

@sbutterfield
Created July 31, 2022 17:29
Show Gist options
  • Save sbutterfield/f68ad0b1c6cfb9665b1dd81b3b7efd69 to your computer and use it in GitHub Desktop.
Save sbutterfield/f68ad0b1c6cfb9665b1dd81b3b7efd69 to your computer and use it in GitHub Desktop.
Efficient initializers for _last in map_ function
export const lastItemInMap = map => Array.from(map).pop();
export const lastKeyInMap = map => Array.from(map.keys()).pop();
export const lastValueInMap = map => Array.from(map.values()).pop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment