Eugene Shmorgun
Eugene Shmorgun

Reputation: 2075

Correctly get access to nested object in JavaScript

I have the JS-object, that in Chrome's console looks as folllow:

data: Object
 comparisonType: "IN"
 dateValue: ""
 numericalValue: 0
 screeningCriterionId: "-4"
 screeningField.displayName: "Prop1"
 screeningField.fieldName: "Prop2"
 screeningField.groupName: "Prop3"
 screeningField.type: "MULTI"
 value: null

And I need to read the screeningField.displayName: "Prop1" from this object , but trying to execute in console this myObject.screeningField.displayName I'm getting the error:

TypeError: Cannot read property 'displayName' of undefined

How to solve my problem ?

Upvotes: 2

Views: 137

Answers (1)

lanzz
lanzz

Reputation: 43168

Apparently the dot is actually included in the key name, try:

myObject['screeningField.displayName']

Upvotes: 5

Related Questions