r/learnjavascript • u/samanthaming • Mar 18 '18
Easier way to create objects with dynamic keys 💪
0
Upvotes
-4
u/samanthaming Mar 18 '18
Easier way to create objects with dynamic keys 💪
Previously, we always had to use the bracket notation to use a dynamic key. With ES6, we can finally create dynamic variable key in the object declaration. Woohoo! 🤩
0
Mar 18 '18
[deleted]
-3
u/samanthaming Mar 18 '18
I didn’t want to mix es6 concepts with the old example and possibly confuse people. Var should definitely be avoided, instead you should use const or let 🙂
12
u/CertainPerformance Mar 18 '18
ES6 way: don't use
var