Skip to content

Instantly share code, notes, and snippets.

@mwj8410
Last active November 10, 2017 22:16
Show Gist options
  • Save mwj8410/da95d31f8f898bfd3127322cbc242ab3 to your computer and use it in GitHub Desktop.
Save mwj8410/da95d31f8f898bfd3127322cbc242ab3 to your computer and use it in GitHub Desktop.
Useful One Line JS operations

Create and array of N size where prefilled with index

Array.from(Array(N).keys());

Working off the previous, makes an onject from that array

Array.from(new Array(24).keys()).reduce((acc, cur, i) => {
  acc[i] = cur
  return acc
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment