Last active
September 28, 2018 00:43
-
-
Save rmbrntt/93f9737209ed787b80dd127e4413f6e8 to your computer and use it in GitHub Desktop.
js-cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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