Reputation: 23
I am trying to search an array with a variable, which seems to not work because it thinks the variable itself is a value.
var variable = "create";
var navViews = {
"create" : [
{
"id" : "1",
"name" : "Create",
"urlext" : "stylecreator"
}
]
}
navViews.variable;
How do I reach "create" through a variable?
Upvotes: 0
Views: 61
Reputation: 15290
If you want to get create array
, you can do this in this way:
navViews[variable]
Upvotes: 2