the short version for {x: x} is {x}
const y = 2;
const short = {x};
assert.deepEqual(short, {y: y});works with multiple variables too
const x = 1;
const y = 2;
const short = {x, y: z};
assert.deepEqual(short, {x: x, y: y});
with methods
using the name only uses it as key
const func = () => func;
const short = {it};
assert.deepEqual(short, {func: func});a different key must be given explicitly, just like before ES6
const func = () => func;
const short = {func};
assert.deepEqual(short, {otherKey: func});inline functions, can written as obj={func(){}} instead of obj={func:function(){}}
const short = {
inlineFunc: 'I am inline'
};
assert.deepEqual(short.inlineFunc(), 'I am inline');