KozzK
Reactiflux4y ago
10 replies
Kozz

✅ – bfrisco – 14-14 Dec 18

Is there any shorthand way to do this?
const obj = {};
obj['a']['b']['c'] = 'a'
// Cannot read properties of undefined (reading 'b')

Current solution:
const obj = {}
obj['a'] = {}
obj['a']['b'] = {};
obj['a']['b']['c'] = 'a';
Was this page helpful?