Is there a short-hand to do the following:
let o = {}
o['a'] = 1;
o['b'] = 2;
For example, either:
let o = {}
o.update({'a': 1, 'b': 2})
Or:
let o = {'a': 1, 'b': 2}
Object.assign
can achieve it.
const o = { original: 'orig' };
Object.assign(o, {'a': 1, 'b': 2});
console.log(o);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With