Guanlun Zhao
Web developer and learner who occasionally writes.
Find me on Github: github.com/guanlun
TIL: ES6 Object Initialization with Expressions

We can actually do this in ES6:

const key = 'foo';
const obj = {
        [key]: 'bar'
};

instead of having to do:

const key = 'foo';
const obj = {};
obj[key] = 'bar';
comments powered by Disqus