Skip to content

Instantly share code, notes, and snippets.

@rmbrntt
Last active September 28, 2018 00:43
Show Gist options
  • Save rmbrntt/93f9737209ed787b80dd127e4413f6e8 to your computer and use it in GitHub Desktop.
Save rmbrntt/93f9737209ed787b80dd127e4413f6e8 to your computer and use it in GitHub Desktop.
js-cheatsheet
# Quick js utils and functions I don't want to rediscover every 3 months
// create an object with keys from the range length of another object
// in: {a: null, b: null}
// out: {1: false, 2: false}
// why? Used an indexed dict to track the state of a grid of items by their index
Array.from({length: Object.keys({a: null, b: null}).length}, (v, k) => k+1)
.reduce((o, key) => ({ ...o, [key]: false}), {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment