fallback for dynamic object using bracket

31 views Asked by At
const result = something[dynamicValue]

Given the above code, I can get error of Cannot read property 'x' of null because something is undefined, how do I fallback check to void error? should I do something like this

const result = something && something[dynamicValue]
0

There are 0 answers