Reputation: 1138
The following command shows the properties of an Object.
var keys = Object.keys(result);
Output: [requester.client.id,request.id]
When I try to print an alert(result[request.id]) or alert(result.request.id) I dont get the values. Is there something I am missing?
Upvotes: 0
Views: 57
Reputation: 115920
Your result
object has properties named "requester.client.id"
and "request.id"
.
You need to do alert(result["request.id"])
.
result[request.id]
does not work because request
here is treated as a variable name, and you probably have no variable named request
.
result.request.id
is closer, but it also fails because the property name has a period in it, so the parser treats this as the the id
property of the request
property of result
.
Upvotes: 0
Reputation: 44889
In JavaScript objects keys are strings, though they can have periods. What you probably getting as the output is ['requester.client.id','request.id']
, so it should be accessed as result['requester.client.id']
.
Upvotes: 2