Skip to content

Instantly share code, notes, and snippets.

@diogobaltazar
Last active December 18, 2018 21:50
Show Gist options
  • Save diogobaltazar/213854c2f078151e78e07ea6e2f2ecde to your computer and use it in GitHub Desktop.
Save diogobaltazar/213854c2f078151e78e07ea6e2f2ecde to your computer and use it in GitHub Desktop.
Map array to array of objects | JS
> [1, 2, 3].map((_, e) => {return {[e]:e}}) // or simply e => ...
[{…}, {…}, {…}]
0: {1: 1}
1: {2: 2}
2: {3: 3}
> a = {b: {c: {}}}
> a.b.c["d"] = a
> a
b:
c:
d:
b: {c: {...}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment