In PHP I can set variable to be $arr['test1'][0]['test2']
But in JavaScript there are no associative arrays but objects. How can I make situation where I have JSON objects that are different always and I want to store fields if there exists, and store null
if not like in PHP.
test1 = temp.test1[0].test
Gives me error - cannot access property test of undefined
.
I know that there is workaround for this that I can check if there is property, but I have many different objects, and there are deeply nested, so I need solution where it is automatic, if whole nested property exist store, if not (or if it is property of undefined) store null
.