Extract Value From Object Using Javascript
Solution 1:
Try var orderedBy = doc.$set['contactDetails.orderedBy'];.
Since an object key is a numeric literal or a valid identifier name, it is necessary to quote the key contactDetails.orderedBy to avoid a syntax error.
Quotes can only be omitted if the property name is a numeric literal or a valid identifier name.
In the case of createdBy key, you could retrieve the value like object.createdBy but in the case of contactDetails.orderedBy you need to quote, so access it via object[contactDetails.orderedBy].
Solution 2:
If you want to manipulate object than you need understand the concept of key and value
see this examples
varobject={
"iAmFirstKey":'I am value',
"i.am.second.key":'i am value'
}
so In your case your contacDetails.orderedBy is not Object inside Object it is an key ("string")
so use like this doc.$set['contacDetails.orderedBy']; you will get your value
Post a Comment for "Extract Value From Object Using Javascript"